fix: anchor Day N to each round's first game instead of lazy first sighting
CI / Lint (push) Successful in 5s
CI / Test (push) Successful in 9s
CI / Build & Push (push) Successful in 19s

The banner read "Day 1 of ~60" on day 2 of the playoffs because the old
anchor recorded whatever date we first polled a playoff game as Day 1.
Now round start dates come from /v1/schedule/playoff-series, so Day N
is authoritative and resets at each round boundary. Drops the noisy
"of ~60" denominator.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-19 13:03:08 -04:00
parent 930247b32f
commit a88e2edef0
7 changed files with 220 additions and 94 deletions
+3 -5
View File
@@ -173,15 +173,15 @@ def ot_label(period):
return "OT" if n == 1 else f"{n}OT"
def today_meta(raw_games, now=None, day_n=None, day_total=None):
def today_meta(raw_games, now=None, day_n=None):
"""Build the banner payload from the raw NHL games list.
`raw_games` is the list inside the NHL score response (each with gameType,
seriesStatus, etc.) — NOT the parsed game dicts. This keeps the dependency
one-way: playoff.py doesn't need to know parse_games' field names.
`day_n` / `day_total` are injected by the caller (from the playoff_cache
module) to keep this function pure and test-friendly.
`day_n` is injected by the caller (from the playoff_cache module) scoped to
the max observed round so the banner resets at each round boundary.
"""
playoff_games = [g for g in raw_games if g.get("gameType") == 3]
playoff_mode = len(playoff_games) > 0
@@ -191,7 +191,6 @@ def today_meta(raw_games, now=None, day_n=None, day_total=None):
"playoff_mode": False,
"round_label": None,
"day_n": None,
"day_total": None,
"series_active": 0,
"elimination_count": 0,
"game7_count": 0,
@@ -218,7 +217,6 @@ def today_meta(raw_games, now=None, day_n=None, day_total=None):
"playoff_mode": True,
"round_label": ROUND_LABELS.get(max_round, f"Round {max_round}"),
"day_n": day_n,
"day_total": day_total,
"series_active": len(series_letters) if series_letters else len(playoff_games),
"elimination_count": elim,
"game7_count": g7,