Skip to content

Commit

Permalink
Merge pull request #1155 from googlefonts/showall
Browse files Browse the repository at this point in the history
Show only latest crater results plus a link to show more
  • Loading branch information
cmyr authored Dec 1, 2024
2 parents 386ef8c + 0f73412 commit 21790aa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
4 changes: 4 additions & 0 deletions fontc_crater/resources/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,7 @@ td.rev {
.diff_info {
padding: 10px 20px;
}

.hidden_row {
display: none;
}
23 changes: 20 additions & 3 deletions fontc_crater/src/ci/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ fn make_html(
console.error(error.message);
}
}
function showAllResults() {
document.querySelectorAll(\".hidden_row\").forEach(e => e.classList.remove(\"hidden_row\"));
document.querySelector(\"#show_all_row\").classList.add(\"hidden_row\");
}
</script>
",
);
Expand Down Expand Up @@ -131,7 +136,12 @@ fn tidy_html(raw_html: &str) -> Result<String, Error> {
}

fn make_table_body(runs: &[RunSummary]) -> Markup {
fn make_row(run: &RunSummary, prev: Option<&RunSummary>, is_most_recent: bool) -> Markup {
fn make_row(
run: &RunSummary,
prev: Option<&RunSummary>,
is_most_recent: bool,
default_visible: bool,
) -> Markup {
let total_diff = make_delta_decoration(
run.stats.total_targets as i32,
prev.map(|p| p.stats.total_targets as i32),
Expand Down Expand Up @@ -192,8 +202,9 @@ fn make_table_body(runs: &[RunSummary]) -> Markup {
}
};
let elapsed = super::format_elapsed_time(&run.began, &run.finished);
let class = (!default_visible).then_some("hidden_row");
html! {
tr.run {
tr class=[class] {
td.date { (run.began.format("%Y-%m-%d %H%M")) span.elapsed { " (" (elapsed) ")"} }
td.rev { a href=(diff_url) { (short_rev) } }
td.total { ( run.stats.total_targets) " " (total_diff) }
Expand All @@ -208,11 +219,17 @@ fn make_table_body(runs: &[RunSummary]) -> Markup {
let iter = runs.iter().enumerate().map(|(i, run)| {
let prev = (i > 0).then(|| &runs[i - 1]);
let is_last = i == runs.len() - 1;
make_row(run, prev, is_last)
let default_visibility = i >= runs.len() - 16;
make_row(run, prev, is_last, default_visibility)
});

html! {
tbody {
tr {
td id="show_all_row" {
a href = "" onclick = "event.preventDefault(); showAllResults();" { "Show all " (runs.len()) " results" }
}
}
@for run in iter {
(run)
}
Expand Down

0 comments on commit 21790aa

Please sign in to comment.