fix issues in core
This commit is contained in:
@@ -5,8 +5,9 @@ import type { ILeagueRepository } from '../../domain/repositories/ILeagueReposit
|
||||
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';
|
||||
import { SeasonDropPolicy, type SeasonDropStrategy } from '../../domain/value-objects/SeasonDropPolicy';
|
||||
import { SeasonStewardingConfig } from '../../domain/value-objects/SeasonStewardingConfig';
|
||||
import type { StewardingDecisionMode } from '../../domain/entities/League';
|
||||
import { RaceTimeOfDay } from '../../domain/value-objects/RaceTimeOfDay';
|
||||
import { LeagueTimezone } from '../../domain/value-objects/LeagueTimezone';
|
||||
import { RecurrenceStrategyFactory } from '../../domain/value-objects/RecurrenceStrategy';
|
||||
@@ -120,6 +121,27 @@ export class CreateSeasonForLeagueUseCase {
|
||||
}
|
||||
}
|
||||
|
||||
private parseDropStrategy(value: unknown): SeasonDropStrategy {
|
||||
if (value === 'none' || value === 'bestNResults' || value === 'dropWorstN') {
|
||||
return value;
|
||||
}
|
||||
return 'none';
|
||||
}
|
||||
|
||||
private parseDecisionMode(value: unknown): StewardingDecisionMode {
|
||||
if (
|
||||
value === 'admin_only' ||
|
||||
value === 'steward_decides' ||
|
||||
value === 'steward_vote' ||
|
||||
value === 'member_vote' ||
|
||||
value === 'steward_veto' ||
|
||||
value === 'member_veto'
|
||||
) {
|
||||
return value;
|
||||
}
|
||||
return 'admin_only';
|
||||
}
|
||||
|
||||
private deriveSeasonPropsFromConfig(config: LeagueConfigFormModel): {
|
||||
schedule?: SeasonSchedule;
|
||||
scoringConfig?: SeasonScoringConfig;
|
||||
@@ -133,11 +155,11 @@ export class CreateSeasonForLeagueUseCase {
|
||||
customScoringEnabled: config.scoring?.customScoringEnabled ?? false,
|
||||
});
|
||||
const dropPolicy = new SeasonDropPolicy({
|
||||
strategy: (config.dropPolicy?.strategy as any) ?? 'none',
|
||||
strategy: this.parseDropStrategy(config.dropPolicy?.strategy),
|
||||
...(config.dropPolicy?.n !== undefined ? { n: config.dropPolicy.n } : {}),
|
||||
});
|
||||
const stewardingConfig = new SeasonStewardingConfig({
|
||||
decisionMode: (config.stewarding?.decisionMode as any) ?? 'auto',
|
||||
decisionMode: this.parseDecisionMode(config.stewarding?.decisionMode),
|
||||
...(config.stewarding?.requiredVotes !== undefined
|
||||
? { requiredVotes: config.stewarding.requiredVotes }
|
||||
: {}),
|
||||
|
||||
Reference in New Issue
Block a user