From 1aa40c0c7cd6e1df27df3c882dad600e75e25060 Mon Sep 17 00:00:00 2001 From: Steven Powell Date: Wed, 28 Aug 2024 11:58:13 -0700 Subject: [PATCH] Sort chart list by ID --- pkg/handler/flake_chart.html | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pkg/handler/flake_chart.html b/pkg/handler/flake_chart.html index 1647794..5e6784c 100644 --- a/pkg/handler/flake_chart.html +++ b/pkg/handler/flake_chart.html @@ -28,6 +28,10 @@ return `https://storage.googleapis.com/minikube-builds/logs/master/${jobId}/${environment}.html${testName ? `#${status}_${testName}` : ``}`; } +function sortByID(a, b) { + return a.id - b.id; +} + // Parse URL search `query` into [{key, value}]. function parseUrlQuery(query) { if (query[0] === '?') { @@ -188,14 +192,14 @@ Date: ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}
Flake Percentage: ${groupData.flakePercentage.toFixed(2)}%
Jobs:
- ${resultArr.map(({ id, status }) => ` - ${id} (${status})`).join("
")} + ${resultArr.sort(sortByID).map(({ id, status }) => ` - ${id} (${status})`).join("
")} `, groupData.avgDuration, `
Date: ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}
Average Duration: ${groupData.avgDuration.toFixed(2)}s
Jobs:
- ${durationArr.map(({ id, duration, status }) => ` - ${id} (${duration}s)`).join("
")} + ${durationArr.sort(sortByID).map(({ id, duration, status }) => ` - ${id} (${duration}s)`).join("
")}
`, ] }) @@ -280,14 +284,14 @@ Date: ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}
Flake Percentage: ${groupData.flakePercentage.toFixed(2)}%
Jobs:
- ${resultArr.map(({ id, status }) => ` - ${id} (${status})`).join("
")} + ${resultArr.sort(sortByID).map(({ id, status }) => ` - ${id} (${status})`).join("
")} `, groupData.avgDuration, `
Date: ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}
Average Duration: ${groupData.avgDuration.toFixed(2)}s
Jobs:
- ${durationArr.map(({ id, duration, status }) => ` - ${id} (${duration}s)`).join("
")} + ${durationArr.sort(sortByID).map(({ id, duration, status }) => ` - ${id} (${duration}s)`).join("
")}
`, ] }) @@ -372,14 +376,14 @@ Date: ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}
Flake Percentage: ${groupData.flakePercentage.toFixed(2)}%
Jobs:
- ${resultArr.map(({ id, status }) => ` - ${id} (${status})`).join("
")} + ${resultArr.sort(sortByID).map(({ id, status }) => ` - ${id} (${status})`).join("
")} `, groupData.avgDuration, `
Date: ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}
Average Duration: ${groupData.avgDuration.toFixed(2)}s
Jobs:
- ${durationArr.map(({ id, duration, status }) => ` - ${id} (${duration}s)`).join("
")} + ${durationArr.sort(sortByID).map(({ id, duration, status }) => ` - ${id} (${duration}s)`).join("
")}
`, ] }) @@ -629,7 +633,7 @@ Date: ${dateTime.toLocaleString([], {dateStyle: 'medium'})}
Flake Percentage: ${+fp.toFixed(2)}%
Jobs:
- ${commitArr.map(({ id, status }) => ` - ${id} (${status})`).join("
")} + ${commitArr.sort(sortByID).map(({ id, status }) => ` - ${id} (${status})`).join("
")} ` ] } @@ -726,7 +730,7 @@ Date: ${dateTime.toLocaleString([], {dateStyle: 'medium'})}
Flake Percentage: ${+fp.toFixed(2)}%
Jobs:
- ${commitArr.map(({ id, status }) => ` - ${id} (${status})`).join("
")} + ${commitArr.sort(sortByID).map(({ id, status }) => ` - ${id} (${status})`).join("
")} ` ]; } @@ -975,4 +979,4 @@
- \ No newline at end of file +