From 331caf78ff38db072a38a75d78944dbe697b9c18 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 20 Nov 2024 11:32:57 +0200 Subject: [PATCH] feat: add per-repository run count (total, failed) to report Signed-off-by: Lars Wirzenius --- src/pages.rs | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/pages.rs b/src/pages.rs index 9b47ba6b..334e529f 100644 --- a/src/pages.rs +++ b/src/pages.rs @@ -161,9 +161,13 @@ impl PageData { } }; + let runs = self.runs(rid); + table.push_child( Element::new(Tag::Tr) - .with_child(Element::new(Tag::Td).with_child(Self::repository(rid, &alias))) + .with_child( + Element::new(Tag::Td).with_child(Self::repository(rid, &alias, runs)), + ) .with_child(Element::new(Tag::Td).with_child(run_ids)) .with_child( Element::new(Tag::Td).with_child( @@ -377,14 +381,27 @@ impl PageData { page.push_to_body(Element::new(Tag::P).with_text(text)); } - fn repository(repo_id: RepoId, alias: &str) -> Element { - Element::new(Tag::A) + fn repository(repo_id: RepoId, alias: &str, runs: Vec<&Run>) -> Element { + let failed = runs + .iter() + .filter(|run| run.result() == Some(&RunResult::Failure)) + .count(); + let total = runs.len(); + + Element::new(Tag::Span) .with_child( - Element::new(Tag::Code) - .with_class("alias)") - .with_text(alias), + Element::new(Tag::A) + .with_child( + Element::new(Tag::Code) + .with_class("alias)") + .with_text(alias), + ) + .with_attribute("href", &format!("{}.html", rid_to_basename(repo_id))), ) - .with_attribute("href", &format!("{}.html", rid_to_basename(repo_id))) + .with_child(Element::new(Tag::Br)) + .with_child(Element::new(Tag::Span).with_text(&format!("{failed} failed runs"))) + .with_child(Element::new(Tag::Br)) + .with_child(Element::new(Tag::Span).with_text(&format!("{total} total runs"))) } fn run_ids(run: Option<&Run>) -> Element {