Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show only latest crater results plus a link to show more #1155

Merged
merged 1 commit into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -129,7 +134,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 @@ -190,8 +200,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 @@ -206,11 +217,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