Skip to content

Commit e1087d2

Browse files
committed
Separate footer from summary table
1 parent 1ac7f10 commit e1087d2

File tree

2 files changed

+8
-33
lines changed

2 files changed

+8
-33
lines changed

site/src/comparison.rs

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use std::collections::{HashMap, HashSet};
1717
use std::error::Error;
1818
use std::hash::Hash;
1919
use std::sync::Arc;
20+
use std::fmt::Write;
2021

2122
type BoxedError = Box<dyn Error + Send + Sync>;
2223

@@ -388,7 +389,6 @@ async fn write_triage_summary(
388389
primary: &ArtifactComparisonSummary,
389390
secondary: &ArtifactComparisonSummary,
390391
) -> String {
391-
use std::fmt::Write;
392392
let mut result = if let Some(pr) = comparison.b.pr {
393393
let title = github::pr_title(pr).await;
394394
format!(
@@ -415,8 +415,6 @@ pub fn write_summary_table(
415415
with_footnotes: bool,
416416
result: &mut String,
417417
) {
418-
use std::fmt::Write;
419-
420418
fn render_stat<F: FnOnce() -> Option<f64>>(count: usize, calculate: F) -> String {
421419
let value = if count > 0 { calculate() } else { None };
422420
value
@@ -538,16 +536,16 @@ pub fn write_summary_table(
538536
}),
539537
largest_change,
540538
]);
539+
}
541540

542-
if with_footnotes {
543-
writeln!(
544-
result,
545-
r#"
541+
pub fn write_summary_table_footer(result: &mut String) {
542+
writeln!(
543+
result,
544+
r#"
546545
[^1]: *number of relevant changes*
547546
[^2]: *the arithmetic mean of the percent change*"#
548-
)
547+
)
549548
.unwrap();
550-
}
551549
}
552550

553551
/// Compare two bounds on a given stat
@@ -1272,9 +1270,6 @@ mod tests {
12721270
| count[^1] | 3 | 0 | 0 | 0 | 3 |
12731271
| mean[^2] | 146.7% | N/A | N/A | N/A | 146.7% |
12741272
| max | 200.0% | N/A | N/A | N/A | 200.0% |
1275-
1276-
[^1]: *number of relevant changes*
1277-
[^2]: *the arithmetic mean of the percent change*
12781273
"#
12791274
.trim_start(),
12801275
);
@@ -1294,9 +1289,6 @@ mod tests {
12941289
| count[^1] | 0 | 0 | 3 | 0 | 3 |
12951290
| mean[^2] | N/A | N/A | -71.7% | N/A | -71.7% |
12961291
| max | N/A | N/A | -80.0% | N/A | -80.0% |
1297-
1298-
[^1]: *number of relevant changes*
1299-
[^2]: *the arithmetic mean of the percent change*
13001292
"#
13011293
.trim_start(),
13021294
);
@@ -1316,9 +1308,6 @@ mod tests {
13161308
| count[^1] | 0 | 0 | 0 | 3 | 0 |
13171309
| mean[^2] | N/A | N/A | N/A | -71.7% | N/A |
13181310
| max | N/A | N/A | N/A | -80.0% | N/A |
1319-
1320-
[^1]: *number of relevant changes*
1321-
[^2]: *the arithmetic mean of the percent change*
13221311
"#
13231312
.trim_start(),
13241313
);
@@ -1338,9 +1327,6 @@ mod tests {
13381327
| count[^1] | 0 | 3 | 0 | 0 | 0 |
13391328
| mean[^2] | N/A | 146.7% | N/A | N/A | N/A |
13401329
| max | N/A | 200.0% | N/A | N/A | N/A |
1341-
1342-
[^1]: *number of relevant changes*
1343-
[^2]: *the arithmetic mean of the percent change*
13441330
"#
13451331
.trim_start(),
13461332
);
@@ -1361,9 +1347,6 @@ mod tests {
13611347
| count[^1] | 2 | 0 | 2 | 0 | 4 |
13621348
| mean[^2] | 150.0% | N/A | -62.5% | N/A | 43.8% |
13631349
| max | 200.0% | N/A | -75.0% | N/A | 200.0% |
1364-
1365-
[^1]: *number of relevant changes*
1366-
[^2]: *the arithmetic mean of the percent change*
13671350
"#
13681351
.trim_start(),
13691352
);
@@ -1386,9 +1369,6 @@ mod tests {
13861369
| count[^1] | 2 | 1 | 2 | 1 | 4 |
13871370
| mean[^2] | 150.0% | 100.0% | -62.5% | -66.7% | 43.8% |
13881371
| max | 200.0% | 100.0% | -75.0% | -66.7% | 200.0% |
1389-
1390-
[^1]: *number of relevant changes*
1391-
[^2]: *the arithmetic mean of the percent change*
13921372
"#
13931373
.trim_start(),
13941374
);
@@ -1407,9 +1387,6 @@ mod tests {
14071387
| count[^1] | 1 | 0 | 1 | 0 | 2 |
14081388
| mean[^2] | 20.0% | N/A | -50.0% | N/A | -15.0% |
14091389
| max | 20.0% | N/A | -50.0% | N/A | -50.0% |
1410-
1411-
[^1]: *number of relevant changes*
1412-
[^2]: *the arithmetic mean of the percent change*
14131390
"#
14141391
.trim_start(),
14151392
);
@@ -1428,9 +1405,6 @@ mod tests {
14281405
| count[^1] | 1 | 0 | 1 | 0 | 2 |
14291406
| mean[^2] | 100.0% | N/A | -16.7% | N/A | 41.7% |
14301407
| max | 100.0% | N/A | -16.7% | N/A | 100.0% |
1431-
1432-
[^1]: *number of relevant changes*
1433-
[^2]: *the arithmetic mean of the percent change*
14341408
"#
14351409
.trim_start(),
14361410
);

site/src/github.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,7 @@ async fn summarize_run(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit:
630630
.unwrap();
631631

632632
write_summary_table(&primary, &secondary, true, &mut message);
633+
write_summary_table_footer(&mut message);
633634
}
634635

635636
let direction = primary.direction().or(secondary.direction());

0 commit comments

Comments
 (0)