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