From 5cdfc19bf812d4f3b0059c5d71735501841800b2 Mon Sep 17 00:00:00 2001 From: spark Date: Mon, 19 Oct 2026 03:18:07 +0100 Subject: [PATCH] Keep a Liga game in the season Liga named when an older calendar is read. Asking for 2022/23 was writing that season onto fixtures that belong to another year, because the same fixture id is updated in place. --- apps/api/src/sports/service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/api/src/sports/service.ts b/apps/api/src/sports/service.ts index d030731..4fd4e2b 100644 --- a/apps/api/src/sports/service.ts +++ b/apps/api/src/sports/service.ts @@ -161,11 +161,16 @@ export class SportsService { async importLigaSeason(season: string): Promise { const comps = await this.deps.db.sportsCompetition.findMany({ where: { provider: "LIGA" } }); const byExternal = new Map(comps.map((c) => [c.externalId, c])); + const asked = season.replace(/\D/g, ""); let saved = 0; for (const month of [7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6]) { for (const f of await this.liga.month(month, season)) { + // A month can answer with another season's games. Those keep the season Liga named, never this one: + // the same fixture id updated in place would move a game out of the season it belongs to. + const theirs = (f.season ?? "").replace(/\D/g, ""); + if (theirs && theirs !== asked) continue; const c = byExternal.get(f.competition); - if (c) saved += await this.saveFixture(c, "LIGA", { ...f, season }); + if (c) saved += await this.saveFixture(c, "LIGA", { ...f, season: asked }); } } this.deps.log.info({ season, saved }, "sports: liga season imported"); -- 2.47.3