feat: on the front status page, tell result run if known

Previously we just said "finished", now we say "finished, success" or
the like.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
This commit is contained in:
Lars Wirzenius
2024-10-16 11:13:15 +03:00
parent 535b159290
commit 513eb2c568
+38 -12
View File
@@ -122,17 +122,20 @@ impl PageData {
);
for (alias, rid) in self.repos() {
let (run_ids, status, info_url) = match self.latest_run(rid) {
Some(run) => (
Self::run_ids(Some(run)),
run.state().to_string(),
Self::info_url(Some(run)),
),
None => (
Self::run_ids(None),
"unknown".to_string(),
Self::info_url(None),
),
let (run_ids, status, info_url) = {
let run = self.latest_run(rid);
match run {
Some(run) => (
Self::run_ids(Some(run)),
Self::run_state(run),
Self::info_url(Some(run)),
),
None => (
Self::run_ids(None),
Self::run_state_unknown(),
Self::info_url(None),
),
}
};
table.push_child(
@@ -143,7 +146,7 @@ impl PageData {
Element::new(Tag::Td).with_child(
Element::new(Tag::Span)
.with_class("run-status")
.with_text(&status),
.with_child(status),
),
)
.with_child(Element::new(Tag::Td).with_child(info_url)),
@@ -238,6 +241,29 @@ impl PageData {
Ok(doc)
}
fn run_state(run: &Run) -> Element {
let status = match run.state() {
RunState::Finished => {
if let Some(result) = run.result() {
format!("{}, {}", run.state(), result)
} else {
format!("{} with unknown result", run.state())
}
}
_ => run.state().to_string(),
};
Element::new(Tag::Span)
.with_class(&status)
.with_text(&status.to_string())
}
fn run_state_unknown() -> Element {
Element::new(Tag::Span)
.with_class("run-status")
.with_text("unknown")
}
fn per_repo_page_as_html(&self, rid: RepoId, alias: &str, timestamp: &str) -> HtmlPage {
let mut doc = HtmlPage::default();