diff --git a/islands/ReportTable.tsx b/islands/ReportTable.tsx index f5f97d9..99ae30e 100644 --- a/islands/ReportTable.tsx +++ b/islands/ReportTable.tsx @@ -60,6 +60,35 @@ function CategorySummary({ ); } +type SortMode = + | "name" + | "pass-rate-desc" + | "pass-rate-asc" + | "pass-count-desc" + | "pass-count-asc"; + +function getSortValue( + report: DayReport, + testNames: string[], + mode: SortMode, +): number { + // Aggregate across all available OSes for sorting + let totalPass = 0; + let totalCount = 0; + for (const os of ["linux", "windows", "darwin"] as const) { + const r = report[os]; + if (!r) continue; + const rate = getRateForSubset(r, testNames); + if (rate) { + totalPass += rate.pass; + totalCount += rate.total; + } + } + if (totalCount === 0) return mode.includes("desc") ? -1 : Infinity; + if (mode.startsWith("pass-rate")) return totalPass / totalCount; + return totalPass; +} + export function ReportTable(props: { class?: string; report: DayReport }) { const { report } = props; @@ -68,6 +97,7 @@ export function ReportTable(props: { class?: string; report: DayReport }) { const date = report.date; const [expanded, setExpanded] = useState>({}); + const [sortMode, setSortMode] = useState("name"); const toggleCategory = (category: string) => { setExpanded((prev) => ({ ...prev, [category]: !prev[category] })); @@ -85,24 +115,59 @@ export function ReportTable(props: { class?: string; report: DayReport }) { setExpanded({}); }; + const sortedCategories = sortMode === "name" + ? testCategories + : [...testCategories].sort((a, b) => { + const va = getSortValue(report, a[1], sortMode); + const vb = getSortValue(report, b[1], sortMode); + return sortMode.endsWith("desc") ? vb - va : va - vb; + }); + return (
-
- - | - +
+
+ Sort: + {( + [ + ["name", "Name"], + ["pass-rate-desc", "Rate \u2193"], + ["pass-rate-asc", "Rate \u2191"], + ["pass-count-desc", "Passing \u2193"], + ["pass-count-asc", "Passing \u2191"], + ] as [SortMode, string][] + ).map(([mode, label]) => ( + + ))} +
+
+ + | + +
@@ -156,7 +221,7 @@ export function ReportTable(props: { class?: string; report: DayReport }) { - {testCategories.map(([category, testNames]) => { + {sortedCategories.map(([category, testNames]) => { testNames.sort(); const linux = report.linux; const windows = report.windows;