From 94db4274a0e85cd224143b87a1383f506c46c108 Mon Sep 17 00:00:00 2001 From: Nils Briggen Date: Fri, 12 Jun 2026 09:25:45 +0200 Subject: [PATCH] =?UTF-8?q?Results=20backfill:=20ESPN=20dates=20are=20US-E?= =?UTF-8?q?astern=20=E2=80=94=20fetch=20both=20candidates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first heal attempt missed both matches: a 02:00 UTC kickoff files under the PREVIOUS day in ESPN's ?dates= param (ET-based), and the backfill skipped today's UTC date entirely. Now any started-but- forgotten fixture triggers fetches for its UTC date and the day before, covering the ET offset in both directions. Co-Authored-By: Claude Fable 5 --- server/src/ingest/scheduler.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/server/src/ingest/scheduler.ts b/server/src/ingest/scheduler.ts index 1ab8d7c..1823910 100644 --- a/server/src/ingest/scheduler.ts +++ b/server/src/ingest/scheduler.ts @@ -117,11 +117,16 @@ export function startScheduler( // look 'scheduled' (fresh DB, or results lost before persistence existed) // gets its date-scoped ESPN scoreboard re-fetched and merged. const resultsBackfill = async (): Promise => { - const today = dateUTC(new Date().toISOString()); + const now = Date.now(); const dates = new Set(); for (const f of state.allFixtures()) { - const d = dateUTC(f.kickoff); - if (d < today && f.status === 'scheduled' && f.home.team && f.away.team) dates.add(d); + const k = new Date(f.kickoff).getTime(); + // a started-but-forgotten fixture: kickoff is past, state still 'scheduled' + if (k > now - 2 * 60 * 60 * 1000 || f.status !== 'scheduled' || !f.home.team || !f.away.team) continue; + // ESPN's ?dates= is US-Eastern-based: a late-UTC kickoff files under the + // previous calendar day there — fetch both candidates + dates.add(dateUTC(f.kickoff)); + dates.add(dateUTC(new Date(k - 24 * 60 * 60 * 1000).toISOString())); } for (const date of dates) { if (stopped) return;