From a8f6a0f03ddcbb8d9f14b7e71197c525e2f620b4 Mon Sep 17 00:00:00 2001 From: spark Date: Mon, 19 Oct 2026 04:09:22 +0100 Subject: [PATCH] Keep each Liga season's matches, because Liga reuses the same fixture code every year. 10101 is one game in 2023 and a different game in 2025. Storing the code alone let the later import overwrite the earlier year. --- apps/api/src/sports/providers.ts | 7 +++++-- apps/api/src/sports/service.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/api/src/sports/providers.ts b/apps/api/src/sports/providers.ts index effae12..6d50ede 100644 --- a/apps/api/src/sports/providers.ts +++ b/apps/api/src/sports/providers.ts @@ -232,11 +232,14 @@ export class LigaProvider { const code = str(f.fixtureCode) ?? `${f.round ?? f.matchweekNumber}-${home.externalId}-${away.externalId}`; const finished = typeof f.fixtureStateTypeId === "number" && f.fixtureStateTypeId >= 5; const named = str(f.seasonCode); + // Liga reuses fixtureCode every season: 10101 is a different match in 2023 and in 2025. The season is part + // of the id, or the later year's import overwrites the earlier year. + const seasonKey = named ?? season; out.push({ - externalId: code, + externalId: `${seasonKey}-${code}`, competition: comp.externalId, competitionName: comp.name, - season: named ?? season, + season: seasonKey, seasonNamed: named !== null, home, away, diff --git a/apps/api/src/sports/service.ts b/apps/api/src/sports/service.ts index 8be50b7..c68bd06 100644 --- a/apps/api/src/sports/service.ts +++ b/apps/api/src/sports/service.ts @@ -854,7 +854,7 @@ export class SportsService { const fixture = event.fixture; if (!named.length && fixture?.competition.provider === "LIGA" && fixture.round) { try { - named = await this.liga.referees(fixture.competition.externalId, fixture.competition.season, fixture.round, fixture.externalId); + named = await this.liga.referees(fixture.competition.externalId, fixture.competition.season, fixture.round, fixture.externalId.replace(/^\d{8}-/, "")); if (named.length) await db.sportsFixture.update({ where: { id: fixture.id }, data: { officials: named as unknown as object } }); } catch (err) { log.warn({ err, fixture: fixture.id }, "sports: liga referees failed"); -- 2.47.3