feat: add per-repository run count (total, failed) to report

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-11-20 11:32:57 +02:00
parent b8027442ca
commit 331caf78ff
+24 -7
View File
@@ -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 {