fix issues in core
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { Season } from '../../domain/entities/Season';
|
||||
import { Season } from '../../domain/entities/season/Season';
|
||||
import { League } from '../../domain/entities/League';
|
||||
import type { ISeasonRepository } from '../../domain/repositories/ISeasonRepository';
|
||||
import type { ILeagueRepository } from '../../domain/repositories/ILeagueRepository';
|
||||
import type { LeagueConfigFormModel } from '../dto/LeagueConfigFormDTO';
|
||||
import type { LeagueConfigFormModel } from '@core/racing/application/dto/LeagueConfigFormDTO';
|
||||
import { SeasonSchedule } from '../../domain/value-objects/SeasonSchedule';
|
||||
import { SeasonScoringConfig } from '../../domain/value-objects/SeasonScoringConfig';
|
||||
import { SeasonDropPolicy } from '../../domain/value-objects/SeasonDropPolicy';
|
||||
@@ -93,7 +93,7 @@ export class CreateSeasonForLeagueUseCase {
|
||||
|
||||
const season = Season.create({
|
||||
id: seasonId,
|
||||
leagueId: league.id,
|
||||
leagueId: league.id.toString(),
|
||||
gameId: input.gameId,
|
||||
name: input.name,
|
||||
year: new Date().getFullYear(),
|
||||
@@ -129,28 +129,28 @@ export class CreateSeasonForLeagueUseCase {
|
||||
} {
|
||||
const schedule = this.buildScheduleFromTimings(config);
|
||||
const scoringConfig = new SeasonScoringConfig({
|
||||
scoringPresetId: config.scoring.patternId ?? 'custom',
|
||||
customScoringEnabled: config.scoring.customScoringEnabled ?? false,
|
||||
scoringPresetId: config.scoring?.patternId ?? 'custom',
|
||||
customScoringEnabled: config.scoring?.customScoringEnabled ?? false,
|
||||
});
|
||||
const dropPolicy = new SeasonDropPolicy({
|
||||
strategy: config.dropPolicy.strategy,
|
||||
...(config.dropPolicy.n !== undefined ? { n: config.dropPolicy.n } : {}),
|
||||
strategy: (config.dropPolicy?.strategy as any) ?? 'none',
|
||||
...(config.dropPolicy?.n !== undefined ? { n: config.dropPolicy.n } : {}),
|
||||
});
|
||||
const stewardingConfig = new SeasonStewardingConfig({
|
||||
decisionMode: config.stewarding.decisionMode,
|
||||
...(config.stewarding.requiredVotes !== undefined
|
||||
decisionMode: (config.stewarding?.decisionMode as any) ?? 'auto',
|
||||
...(config.stewarding?.requiredVotes !== undefined
|
||||
? { requiredVotes: config.stewarding.requiredVotes }
|
||||
: {}),
|
||||
requireDefense: config.stewarding.requireDefense,
|
||||
defenseTimeLimit: config.stewarding.defenseTimeLimit,
|
||||
voteTimeLimit: config.stewarding.voteTimeLimit,
|
||||
protestDeadlineHours: config.stewarding.protestDeadlineHours,
|
||||
stewardingClosesHours: config.stewarding.stewardingClosesHours,
|
||||
notifyAccusedOnProtest: config.stewarding.notifyAccusedOnProtest,
|
||||
notifyOnVoteRequired: config.stewarding.notifyOnVoteRequired,
|
||||
requireDefense: config.stewarding?.requireDefense ?? false,
|
||||
defenseTimeLimit: config.stewarding?.defenseTimeLimit ?? 0,
|
||||
voteTimeLimit: config.stewarding?.voteTimeLimit ?? 0,
|
||||
protestDeadlineHours: config.stewarding?.protestDeadlineHours ?? 0,
|
||||
stewardingClosesHours: config.stewarding?.stewardingClosesHours ?? 0,
|
||||
notifyAccusedOnProtest: config.stewarding?.notifyAccusedOnProtest ?? false,
|
||||
notifyOnVoteRequired: config.stewarding?.notifyOnVoteRequired ?? false,
|
||||
});
|
||||
|
||||
const structure = config.structure;
|
||||
const structure = config.structure ?? {};
|
||||
const maxDrivers =
|
||||
typeof structure.maxDrivers === 'number' && structure.maxDrivers > 0
|
||||
? structure.maxDrivers
|
||||
@@ -169,14 +169,14 @@ export class CreateSeasonForLeagueUseCase {
|
||||
config: LeagueConfigFormModel,
|
||||
): SeasonSchedule | undefined {
|
||||
const { timings } = config;
|
||||
if (!timings.seasonStartDate || !timings.raceStartTime) {
|
||||
if (!timings || !timings.seasonStartDate || !timings.raceStartTime) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const startDate = new Date(timings.seasonStartDate);
|
||||
const timeOfDay = RaceTimeOfDay.fromString(timings.raceStartTime);
|
||||
const timezoneId = timings.timezoneId ?? 'UTC';
|
||||
const timezone = new LeagueTimezone(timezoneId);
|
||||
const timezone = LeagueTimezone.create(timezoneId);
|
||||
|
||||
const plannedRounds =
|
||||
typeof timings.roundsPlanned === 'number' && timings.roundsPlanned > 0
|
||||
@@ -197,10 +197,10 @@ export class CreateSeasonForLeagueUseCase {
|
||||
weekdays,
|
||||
);
|
||||
case 'monthlyNthWeekday': {
|
||||
const pattern = new MonthlyRecurrencePattern({
|
||||
ordinal: (timings.monthlyOrdinal ?? 1) as 1 | 2 | 3 | 4,
|
||||
weekday: (timings.monthlyWeekday ?? 'Mon') as Weekday,
|
||||
});
|
||||
const pattern = MonthlyRecurrencePattern.create(
|
||||
(timings.monthlyOrdinal ?? 1) as 1 | 2 | 3 | 4,
|
||||
(timings.monthlyWeekday ?? 'Mon') as Weekday,
|
||||
);
|
||||
return RecurrenceStrategyFactory.monthlyNthWeekday(pattern);
|
||||
}
|
||||
case 'weekly':
|
||||
@@ -214,7 +214,7 @@ export class CreateSeasonForLeagueUseCase {
|
||||
timeOfDay,
|
||||
timezone,
|
||||
recurrence,
|
||||
plannedRounds,
|
||||
plannedRounds: plannedRounds ?? 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user