use optional member
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-14 11:12:43 +02:00
parent f8b9c32e0c
commit dc82d7baf8
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -17,9 +17,9 @@ pub async fn page(config: web::Data<Config>) -> impl Responder {
#[derive(Content)]
struct PortfolioTemplate {
error: bool,
projects: Vec<Project>,
waiting: Vec<Project>,
closed: Vec<Project>,
projects: Option<Vec<Project>>,
waiting: Option<Vec<Project>>,
closed: Option<Vec<Project>>,
}
#[derive(Content, Clone)]
@ -94,21 +94,24 @@ pub async fn get_page(config: Config) -> std::string::String {
PortfolioTemplate {
error: false,
projects: data
.iter()
projects: Some(
data.iter()
.cloned()
.filter(|p| !p.pulls_merged.is_empty())
.collect(),
waiting: data
.iter()
),
waiting: Some(
data.iter()
.cloned()
.filter(|p| !p.pulls_open.is_empty())
.collect(),
closed: data
.iter()
),
closed: Some(
data.iter()
.cloned()
.filter(|p| !p.pulls_closed.is_empty())
.collect(),
),
}
}
Err(e) => {
@ -116,9 +119,9 @@ pub async fn get_page(config: Config) -> std::string::String {
PortfolioTemplate {
error: true,
projects: Vec::new(),
waiting: Vec::new(),
closed: Vec::new(),
projects: None,
waiting: None,
closed: None,
}
}
};