Skip to content

Commit 4f6b84a

Browse files
authored
Sort kernels by score (highest first) for leaderboard view (#54)
1 parent e5a8ad0 commit 4f6b84a

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

site/app/components/CardsContent.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ import { TooltipProvider } from '@/components/ui/tooltip';
55
import { Header } from '@/components/Header';
66
import { KernelCard } from '@/components/KernelCard';
77
import type { ConformanceMatrix } from '@/types/report';
8+
import { getPassedCount, getTotalCount } from '@/types/report';
89

910
interface CardsContentProps {
1011
data: ConformanceMatrix;
1112
}
1213

1314
export function CardsContent({ data }: CardsContentProps) {
15+
// Sort reports by score (highest first)
16+
const sortedReports = [...data.reports].sort((a, b) => {
17+
const aPercent = getTotalCount(a) > 0 ? getPassedCount(a) / getTotalCount(a) : 0;
18+
const bPercent = getTotalCount(b) > 0 ? getPassedCount(b) / getTotalCount(b) : 0;
19+
return bPercent - aPercent;
20+
});
1421

1522
return (
1623
<TooltipProvider>
@@ -46,7 +53,7 @@ export function CardsContent({ data }: CardsContentProps) {
4653

4754
{/* Kernel cards grid */}
4855
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
49-
{data.reports.map((report) => (
56+
{sortedReports.map((report) => (
5057
<KernelCard
5158
key={report.kernel_name}
5259
report={report}

site/src/components/ConformanceMatrix.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,19 @@ function getScoreColor(percentage: number): string {
2929
return 'text-ctp-red';
3030
}
3131

32+
/** Sort reports by score (highest first) */
33+
function sortByScore(reports: MatrixType['reports']) {
34+
return [...reports].sort((a, b) => {
35+
const aPercent = getTotalCount(a) > 0 ? getPassedCount(a) / getTotalCount(a) : 0;
36+
const bPercent = getTotalCount(b) > 0 ? getPassedCount(b) / getTotalCount(b) : 0;
37+
return bPercent - aPercent;
38+
});
39+
}
40+
3241
/** Summary table showing tier scores for each kernel */
3342
export function SummaryTable({ matrix }: ConformanceMatrixProps) {
43+
const sortedReports = sortByScore(matrix.reports);
44+
3445
return (
3546
<div className="rounded-lg border border-ctp-surface0 overflow-x-auto bg-ctp-mantle">
3647
<Table>
@@ -47,7 +58,7 @@ export function SummaryTable({ matrix }: ConformanceMatrixProps) {
4758
</TableRow>
4859
</TableHeader>
4960
<TableBody>
50-
{matrix.reports.map((report) => {
61+
{sortedReports.map((report) => {
5162
const passed = getPassedCount(report);
5263
const total = getTotalCount(report);
5364
const percentage = total > 0 ? Math.round((passed / total) * 100) : 0;
@@ -101,6 +112,7 @@ export function SummaryTable({ matrix }: ConformanceMatrixProps) {
101112

102113
/** Detailed matrix showing all tests vs all kernels */
103114
export function DetailedMatrix({ matrix }: ConformanceMatrixProps) {
115+
const sortedReports = sortByScore(matrix.reports);
104116
const testNames = getAllTestNames(matrix);
105117

106118
// Group tests by category for display
@@ -128,7 +140,7 @@ export function DetailedMatrix({ matrix }: ConformanceMatrixProps) {
128140
<TableHeader className="sticky top-0 z-20 bg-ctp-mantle">
129141
<TableRow className="border-ctp-surface0 hover:bg-transparent">
130142
<TableHead className="min-w-[200px] sticky left-0 z-30 bg-ctp-mantle text-ctp-subtext0">Test</TableHead>
131-
{matrix.reports.map((report) => {
143+
{sortedReports.map((report) => {
132144
const LanguageIcon = getLanguageIcon(report.kernel_name, report.language);
133145
return (
134146
<TableHead key={report.kernel_name} className="text-center min-w-[80px] text-ctp-subtext0 py-3 bg-ctp-mantle">
@@ -153,7 +165,7 @@ export function DetailedMatrix({ matrix }: ConformanceMatrixProps) {
153165
<TableCell className="font-semibold text-xs uppercase tracking-wide sticky left-0 z-10 bg-ctp-surface0 text-ctp-mauve">
154166
{TIER_DESCRIPTIONS[tier]}
155167
</TableCell>
156-
{matrix.reports.map((report) => (
168+
{sortedReports.map((report) => (
157169
<TableCell key={report.kernel_name} className="bg-ctp-surface0" />
158170
))}
159171
</TableRow>
@@ -163,7 +175,7 @@ export function DetailedMatrix({ matrix }: ConformanceMatrixProps) {
163175
<TableCell className="font-mono text-xs sticky left-0 z-10 bg-ctp-mantle text-ctp-text">
164176
{testName}
165177
</TableCell>
166-
{matrix.reports.map((report) => {
178+
{sortedReports.map((report) => {
167179
const test = report.results.find((t) => t.name === testName);
168180
return (
169181
<TableCell key={report.kernel_name} className="text-center">

0 commit comments

Comments
 (0)