refactor: remove legacy round-robin repair

This commit is contained in:
dahyeon committed 2026-06-19 01:36:34 -07:00
1 parent 7399968fe8
commit ade5735dc2
3 files changed
+39 -54

No files matched your search

@@ -395,7 +395,7 @@ export class TournamentCodeService {
const gameMode = match.gameMode ?? 'pair';
if (gameMode === 'round-robin') {
if (this.shouldUsePersistedRoundRobinSchedule(match)) {
if ((match.gameSchedule?.length ?? 0) > 0) {
return match.gameSchedule.length;
}
return this.buildRoundRobinGameSchedule(match).length;
@@ -422,12 +422,10 @@ export class TournamentCodeService {
(entry) => entry.gameNumber === gameNumber,
);
if (persisted) {
if (this.shouldUsePersistedRoundRobinSchedule(match)) {
return {
teamAIndex: persisted.teamAIndex,
teamBIndex: persisted.teamBIndex,
};
}
return {
teamAIndex: persisted.teamAIndex,
teamBIndex: persisted.teamBIndex,
};
}
const fallback = this.buildRoundRobinGameSchedule(match).find(
@@ -454,10 +452,10 @@ export class TournamentCodeService {
private ensureGameSchedule(match: MatchDocument): void {
if ((match.gameMode ?? 'pair') !== 'round-robin') return;
if ((match.gameSchedule?.length ?? 0) > 0) return;
const teamCount = resolveRoundRobinTeamCount(match);
if (teamCount < 2) return;
if (this.shouldUsePersistedRoundRobinSchedule(match)) return;
match.gameSchedule = this.buildRoundRobinGameSchedule(match);
}
@@ -471,33 +469,13 @@ export class TournamentCodeService {
const persisted = match.gameSchedule?.find(
(entry) => entry.gameNumber === gameNumber,
);
if (persisted) {
if (persisted.roundNumber) return persisted.roundNumber;
if (this.shouldUsePersistedRoundRobinSchedule(match)) return undefined;
}
if (persisted) return persisted.roundNumber;
return this.buildRoundRobinGameSchedule(match).find(
(entry) => entry.gameNumber === gameNumber,
)?.roundNumber;
}
private shouldUsePersistedRoundRobinSchedule(match: MatchDocument): boolean {
const schedule = match.gameSchedule ?? [];
if (schedule.length === 0) return false;
if (schedule.every((entry) => typeof entry.roundNumber === 'number')) {
return true;
}
return !this.canRegenerateRoundRobinSchedule(match);
}
private canRegenerateRoundRobinSchedule(match: MatchDocument): boolean {
return (
(match.tournamentCodeIds?.length ?? 0) === 0 &&
(match.result?.games?.length ?? 0) === 0
);
}
private buildRoundRobinGameSchedule(
match: MatchDocument,
shuffleTeams = false,