Skip to content

Commit

Permalink
Merge pull request #161 from spowelljr/sortByID
Browse files Browse the repository at this point in the history
Sort chart list by ID
  • Loading branch information
medyagh authored Aug 29, 2024
2 parents 7072e81 + 1aa40c0 commit 8ea8f2e
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions pkg/handler/flake_chart.html
Original file line number Diff line number Diff line change
Expand Up @@ -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] === '?') {
Expand Down Expand Up @@ -188,14 +192,14 @@
<b>Date:</b> ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}<br>
<b>Flake Percentage:</b> ${groupData.flakePercentage.toFixed(2)}%<br>
<b>Jobs:</b><br>
${resultArr.map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${status})`).join("<br>")}
${resultArr.sort(sortByID).map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${status})`).join("<br>")}
</div>`,
groupData.avgDuration,
`<div style="padding: 1rem; font-family: 'Arial'; font-size: 14">
<b>Date:</b> ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}<br>
<b>Average Duration:</b> ${groupData.avgDuration.toFixed(2)}s<br>
<b>Jobs:</b><br>
${durationArr.map(({ id, duration, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${duration}s)`).join("<br>")}
${durationArr.sort(sortByID).map(({ id, duration, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${duration}s)`).join("<br>")}
</div>`,
]
})
Expand Down Expand Up @@ -280,14 +284,14 @@
<b>Date:</b> ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}<br>
<b>Flake Percentage:</b> ${groupData.flakePercentage.toFixed(2)}%<br>
<b>Jobs:</b><br>
${resultArr.map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${status})`).join("<br>")}
${resultArr.sort(sortByID).map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${status})`).join("<br>")}
</div>`,
groupData.avgDuration,
`<div style="padding: 1rem; font-family: 'Arial'; font-size: 14">
<b>Date:</b> ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}<br>
<b>Average Duration:</b> ${groupData.avgDuration.toFixed(2)}s<br>
<b>Jobs:</b><br>
${durationArr.map(({ id, duration, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${duration}s)`).join("<br>")}
${durationArr.sort(sortByID).map(({ id, duration, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${duration}s)`).join("<br>")}
</div>`,
]
})
Expand Down Expand Up @@ -372,14 +376,14 @@
<b>Date:</b> ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}<br>
<b>Flake Percentage:</b> ${groupData.flakePercentage.toFixed(2)}%<br>
<b>Jobs:</b><br>
${resultArr.map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${status})`).join("<br>")}
${resultArr.sort(sortByID).map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${status})`).join("<br>")}
</div>`,
groupData.avgDuration,
`<div style="padding: 1rem; font-family: 'Arial'; font-size: 14">
<b>Date:</b> ${groupData.startOfDate.toLocaleString([], {dateStyle: 'medium'})}<br>
<b>Average Duration:</b> ${groupData.avgDuration.toFixed(2)}s<br>
<b>Jobs:</b><br>
${durationArr.map(({ id, duration, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${duration}s)`).join("<br>")}
${durationArr.sort(sortByID).map(({ id, duration, status }) => ` - <a href="${testGopoghLink(id, query.env, query.test, status)}">${id}</a> (${duration}s)`).join("<br>")}
</div>`,
]
})
Expand Down Expand Up @@ -629,7 +633,7 @@
<b>Date:</b> ${dateTime.toLocaleString([], {dateStyle: 'medium'})}<br>
<b>Flake Percentage:</b> ${+fp.toFixed(2)}%<br>
<b>Jobs:</b><br>
${commitArr.map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, name, status)}">${id}</a> (${status})`).join("<br>")}
${commitArr.sort(sortByID).map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, name, status)}">${id}</a> (${status})`).join("<br>")}
</div>`
]
}
Expand Down Expand Up @@ -726,7 +730,7 @@
<b>Date:</b> ${dateTime.toLocaleString([], {dateStyle: 'medium'})}<br>
<b>Flake Percentage:</b> ${+fp.toFixed(2)}%<br>
<b>Jobs:</b><br>
${commitArr.map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, name, status)}">${id}</a> (${status})`).join("<br>")}
${commitArr.sort(sortByID).map(({ id, status }) => ` - <a href="${testGopoghLink(id, query.env, name, status)}">${id}</a> (${status})`).join("<br>")}
</div>`
];
}
Expand Down Expand Up @@ -975,4 +979,4 @@
<div id="chart_div"></div>
<div id="version_div"></div>
</body>
</html>
</html>

0 comments on commit 8ea8f2e

Please sign in to comment.