wip
This commit is contained in:
@@ -33,10 +33,14 @@ export class GetLeagueScoringConfigUseCase
|
||||
if (!seasons || seasons.length === 0) {
|
||||
throw new Error(`No seasons found for league ${leagueId}`);
|
||||
}
|
||||
|
||||
|
||||
const activeSeason =
|
||||
seasons.find((s) => s.status === 'active') ?? seasons[0];
|
||||
|
||||
|
||||
if (!activeSeason) {
|
||||
throw new Error(`No active season could be determined for league ${leagueId}`);
|
||||
}
|
||||
|
||||
const scoringConfig =
|
||||
await this.leagueScoringConfigRepository.findBySeasonId(activeSeason.id);
|
||||
if (!scoringConfig) {
|
||||
@@ -50,14 +54,14 @@ export class GetLeagueScoringConfigUseCase
|
||||
|
||||
const presetId = scoringConfig.scoringPresetId;
|
||||
const preset = presetId ? this.presetProvider.getPresetById(presetId) : undefined;
|
||||
|
||||
|
||||
const data: LeagueScoringConfigData = {
|
||||
leagueId: league.id,
|
||||
seasonId: activeSeason.id,
|
||||
gameId: game.id,
|
||||
gameName: game.name,
|
||||
scoringPresetId: presetId,
|
||||
preset,
|
||||
...(presetId !== undefined ? { scoringPresetId: presetId } : {}),
|
||||
...(preset !== undefined ? { preset } : {}),
|
||||
championships: scoringConfig.championships,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user