fix issues in core
This commit is contained in:
@@ -7,12 +7,13 @@ import { LeagueTimezone } from '../../domain/value-objects/LeagueTimezone';
|
||||
import { MonthlyRecurrencePattern } from '../../domain/value-objects/MonthlyRecurrencePattern';
|
||||
import { RaceTimeOfDay } from '../../domain/value-objects/RaceTimeOfDay';
|
||||
import { RecurrenceStrategyFactory } from '../../domain/value-objects/RecurrenceStrategy';
|
||||
import { SeasonDropPolicy } from '../../domain/value-objects/SeasonDropPolicy';
|
||||
import { SeasonDropPolicy, type SeasonDropStrategy } from '../../domain/value-objects/SeasonDropPolicy';
|
||||
import { SeasonSchedule } from '../../domain/value-objects/SeasonSchedule';
|
||||
import { SeasonScoringConfig } from '../../domain/value-objects/SeasonScoringConfig';
|
||||
import { SeasonStewardingConfig } from '../../domain/value-objects/SeasonStewardingConfig';
|
||||
import { WeekdaySet } from '../../domain/value-objects/WeekdaySet';
|
||||
import type { LeagueConfigFormModel } from '../dto/LeagueConfigFormDTO';
|
||||
import type { StewardingDecisionMode } from '../../domain/entities/League';
|
||||
|
||||
// TODO The whole file mixes a lot of concerns...should be resolved into use cases or is it obsolet?
|
||||
|
||||
@@ -280,6 +281,27 @@ export class SeasonApplicationService {
|
||||
};
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -298,14 +320,14 @@ export class SeasonApplicationService {
|
||||
|
||||
const dropPolicy = config.dropPolicy
|
||||
? new SeasonDropPolicy({
|
||||
strategy: config.dropPolicy.strategy as any,
|
||||
strategy: this.parseDropStrategy(config.dropPolicy.strategy),
|
||||
...(config.dropPolicy.n !== undefined ? { n: config.dropPolicy.n } : {}),
|
||||
})
|
||||
: undefined;
|
||||
|
||||
const stewardingConfig = config.stewarding
|
||||
? new SeasonStewardingConfig({
|
||||
decisionMode: config.stewarding.decisionMode as any,
|
||||
decisionMode: this.parseDecisionMode(config.stewarding.decisionMode),
|
||||
...(config.stewarding.requiredVotes !== undefined
|
||||
? { requiredVotes: config.stewarding.requiredVotes }
|
||||
: {}),
|
||||
|
||||
Reference in New Issue
Block a user