▍ humdrum codex / soft

Scores: order each tier Active -> Finished -> Upcoming

850296b34330247ebf6d19af416722155361d693
humdrum <me@humdrum.me> · 2026-07-08 17:51

parent 6d454fcb

Scores: order each tier Active -> Finished -> Upcoming

Was Finished -> Today(live+scheduled) -> Upcoming. Now live games sort first,
then finals, then scheduled — in both the TUI and the paper.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

2 files changed

app/print/page.tsx +4 −6
@@ -287,13 +287,11 @@     case "sports": {
       const p = payload as SportsPayload;
       if (p.games.length === 0) return null;
       type G = SportsPayload["games"][number];
-      const sameDay = (iso: string | null) =>
-        iso ? new Date(iso).toDateString() === new Date().toDateString() : true;
-      // Order within a tier: yesterday's finals, then today's/live, then upcoming.
+      // Order within a tier: Active (live), then Finished, then Upcoming.
       const rank = (g: G): number => {
-        if (g.state === "post") return 0;
-        if (g.state === "in") return 1;
-        return sameDay(g.startTime) ? 1 : 2;
+        if (g.state === "in") return 0;
+        if (g.state === "post") return 1;
+        return 2;
       };
       const line = (g: G) =>
         g.state === "pre"
tui/dashboard.py +7 −18
@@ -409,25 +409,14 @@             t.append(f"  {src}\n", style="dim")
     return t
 
 
-def _game_bucket(g: dict) -> str:
+# Sort order within a tier: Active (live) → Finished → Upcoming (scheduled).
+def _game_order(g: dict) -> int:
     state = g.get("state")
-    if state == "post":
-        return "final"
     if state == "in":
-        return "today"
-    # pre or unknown — classify by date
-    st = g.get("startTime")
-    if st:
-        try:
-            d = to_local(st)
-            return "today" if d.date() == date.today() else "upcoming"
-        except Exception:
-            pass
-    return "today"
-
-
-# Sort order within a tier: yesterday's finals, then today/live, then upcoming.
-_GAME_RANK = {"final": 0, "today": 1, "upcoming": 2}
+        return 0
+    if state == "post":
+        return 1
+    return 2
 
 
 def _game_label(g: dict) -> tuple[str, str]:
@@ -481,7 +470,7 @@         t.append(f"{title}\n", style="bold")
 
         group = sorted(
             group,
-            key=lambda g: (_GAME_RANK.get(_game_bucket(g), 1), g.get("startTime") or ""),
+            key=lambda g: (_game_order(g), g.get("startTime") or ""),
         )
         cur_league = None
         for g in group: