feat(ui): order projects by their newest problem

Projects now sort by the newest alert they hold, whether a failing workflow, a waiting pull request or a stale issue. Projects with equal ages keep the server order.
This commit is contained in:
2026-10-03 00:14:23 +01:00
parent 8cbc495dc7
commit 9446caaf1b
3 changed files with 62 additions and 7 deletions
+6 -2
View File
@@ -19,7 +19,9 @@ const SCAN_TIMEOUT_MS = 10 * 60 * 1000
const SEVERITY_RANK = { ok: 0, warn: 1, crit: 2 } as const
/** Groups alerts into one row per target URL and one block per unhealthy repo. */
const sinceMs = (since: string) => Date.parse(since) || 0
/** Groups alerts into one row per target URL and one block per unhealthy repo, newest problem first. */
export function buildBlocks(state: TrackerState): Block[] {
const rows = new Map<string, Row>()
const order = new Map<string, string[]>()
@@ -32,6 +34,7 @@ export function buildBlocks(state: TrackerState): Block[] {
if (SEVERITY_RANK[alert.severity] > SEVERITY_RANK[existing.severity]) {
existing.severity = alert.severity
}
if (sinceMs(alert.since) > sinceMs(existing.since)) existing.since = alert.since
continue
}
rows.set(key, {
@@ -52,7 +55,8 @@ export function buildBlocks(state: TrackerState): Block[] {
list.sort((a, b) => SEVERITY_RANK[b.severity] - SEVERITY_RANK[a.severity])
blocks.push({ repo, rows: list })
}
return blocks
const newest = (b: Block) => Math.max(...b.rows.map((r) => sinceMs(r.since)))
return blocks.sort((a, b) => newest(b) - newest(a))
}
export interface RepoCounts {