Keep each Liga game in the season Liga named #39
No files matched your search
@@ -42,6 +42,8 @@ export interface FixtureData {
|
||||
competitionName?: string;
|
||||
gender?: string | null;
|
||||
season: string;
|
||||
/** Liga named this season on the fixture. Absent means the caller asked for a season and Liga did not confirm it. */
|
||||
seasonNamed?: boolean;
|
||||
home: TeamData;
|
||||
away: TeamData;
|
||||
startsAt: Date;
|
||||
@@ -229,11 +231,13 @@ export class LigaProvider {
|
||||
if (!comp || !home || !away || !when || f.canceledFixture) continue;
|
||||
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);
|
||||
out.push({
|
||||
externalId: code,
|
||||
competition: comp.externalId,
|
||||
competitionName: comp.name,
|
||||
season: str(f.seasonCode) ?? season,
|
||||
season: named ?? season,
|
||||
seasonNamed: named !== null,
|
||||
home,
|
||||
away,
|
||||
startsAt: new Date(when),
|
||||
|
||||
@@ -167,10 +167,13 @@ export class SportsService {
|
||||
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;
|
||||
// Only a season Liga itself named. Guessing the season we asked for would move another year's game
|
||||
// onto this one, because the fixture id is updated in place.
|
||||
if (!f.seasonNamed) continue;
|
||||
const theirs = f.season.replace(/\D/g, "");
|
||||
if (theirs !== asked) continue;
|
||||
const c = byExternal.get(f.competition);
|
||||
if (c) saved += await this.saveFixture(c, "LIGA", { ...f, season: asked });
|
||||
if (c) saved += await this.saveFixture(c, "LIGA", f);
|
||||
}
|
||||
}
|
||||
this.deps.log.info({ season, saved }, "sports: liga season imported");
|
||||
|
||||
Reference in new issue
Block a user