Results backfill: ESPN dates are US-Eastern — fetch both candidates

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 <noreply@anthropic.com>
This commit is contained in:
2026-06-12 09:25:45 +02:00
parent 66cbbc3dde
commit 94db4274a0
+8 -3
View File
@@ -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<void> => {
const today = dateUTC(new Date().toISOString());
const now = Date.now();
const dates = new Set<string>();
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;