wip league admin tools
This commit is contained in:
@@ -22,6 +22,7 @@ export class Season implements IEntity<string> {
|
||||
readonly startDate: Date | undefined;
|
||||
readonly endDate: Date | undefined;
|
||||
readonly schedule: SeasonSchedule | undefined;
|
||||
readonly schedulePublished: boolean;
|
||||
readonly scoringConfig: SeasonScoringConfig | undefined;
|
||||
readonly dropPolicy: SeasonDropPolicy | undefined;
|
||||
readonly stewardingConfig: SeasonStewardingConfig | undefined;
|
||||
@@ -41,6 +42,7 @@ export class Season implements IEntity<string> {
|
||||
startDate?: Date;
|
||||
endDate?: Date;
|
||||
schedule?: SeasonSchedule;
|
||||
schedulePublished: boolean;
|
||||
scoringConfig?: SeasonScoringConfig;
|
||||
dropPolicy?: SeasonDropPolicy;
|
||||
stewardingConfig?: SeasonStewardingConfig;
|
||||
@@ -57,6 +59,7 @@ export class Season implements IEntity<string> {
|
||||
this.startDate = props.startDate;
|
||||
this.endDate = props.endDate;
|
||||
this.schedule = props.schedule;
|
||||
this.schedulePublished = props.schedulePublished;
|
||||
this.scoringConfig = props.scoringConfig;
|
||||
this.dropPolicy = props.dropPolicy;
|
||||
this.stewardingConfig = props.stewardingConfig;
|
||||
@@ -75,6 +78,7 @@ export class Season implements IEntity<string> {
|
||||
startDate?: Date;
|
||||
endDate?: Date | undefined;
|
||||
schedule?: SeasonSchedule;
|
||||
schedulePublished?: boolean;
|
||||
scoringConfig?: SeasonScoringConfig;
|
||||
dropPolicy?: SeasonDropPolicy;
|
||||
stewardingConfig?: SeasonStewardingConfig;
|
||||
@@ -162,6 +166,7 @@ export class Season implements IEntity<string> {
|
||||
...(props.startDate !== undefined ? { startDate: props.startDate } : {}),
|
||||
...(props.endDate !== undefined ? { endDate: props.endDate } : {}),
|
||||
...(props.schedule !== undefined ? { schedule: props.schedule } : {}),
|
||||
schedulePublished: props.schedulePublished ?? false,
|
||||
...(props.scoringConfig !== undefined ? { scoringConfig: props.scoringConfig } : {}),
|
||||
...(props.dropPolicy !== undefined ? { dropPolicy: props.dropPolicy } : {}),
|
||||
...(props.stewardingConfig !== undefined ? { stewardingConfig: props.stewardingConfig } : {}),
|
||||
@@ -348,16 +353,16 @@ export class Season implements IEntity<string> {
|
||||
* Cancel a planned or active season.
|
||||
*/
|
||||
cancel(): Season {
|
||||
// If already cancelled, return this (idempotent).
|
||||
if (this.status.isCancelled()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
const transition = this.status.canTransitionTo('cancelled');
|
||||
if (!transition.valid) {
|
||||
throw new RacingDomainInvariantError(transition.error!);
|
||||
}
|
||||
|
||||
// If already cancelled, return this
|
||||
if (this.status.isCancelled()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// Ensure end date is set
|
||||
const endDate = this.endDate ?? new Date();
|
||||
|
||||
@@ -400,6 +405,28 @@ export class Season implements IEntity<string> {
|
||||
...(this.startDate !== undefined ? { startDate: this.startDate } : {}),
|
||||
...(this.endDate !== undefined ? { endDate: this.endDate } : {}),
|
||||
schedule,
|
||||
schedulePublished: this.schedulePublished,
|
||||
...(this.scoringConfig !== undefined ? { scoringConfig: this.scoringConfig } : {}),
|
||||
...(this.dropPolicy !== undefined ? { dropPolicy: this.dropPolicy } : {}),
|
||||
...(this.stewardingConfig !== undefined ? { stewardingConfig: this.stewardingConfig } : {}),
|
||||
...(this.maxDrivers !== undefined ? { maxDrivers: this.maxDrivers } : {}),
|
||||
participantCount: this._participantCount.toNumber(),
|
||||
});
|
||||
}
|
||||
|
||||
withSchedulePublished(published: boolean): Season {
|
||||
return Season.create({
|
||||
id: this.id,
|
||||
leagueId: this.leagueId,
|
||||
gameId: this.gameId,
|
||||
name: this.name,
|
||||
...(this.year !== undefined ? { year: this.year } : {}),
|
||||
...(this.order !== undefined ? { order: this.order } : {}),
|
||||
status: this.status.toString(),
|
||||
...(this.startDate !== undefined ? { startDate: this.startDate } : {}),
|
||||
...(this.endDate !== undefined ? { endDate: this.endDate } : {}),
|
||||
...(this.schedule !== undefined ? { schedule: this.schedule } : {}),
|
||||
schedulePublished: published,
|
||||
...(this.scoringConfig !== undefined ? { scoringConfig: this.scoringConfig } : {}),
|
||||
...(this.dropPolicy !== undefined ? { dropPolicy: this.dropPolicy } : {}),
|
||||
...(this.stewardingConfig !== undefined ? { stewardingConfig: this.stewardingConfig } : {}),
|
||||
@@ -544,16 +571,16 @@ export class Season implements IEntity<string> {
|
||||
leagueId: this.leagueId,
|
||||
gameId: this.gameId,
|
||||
name: this.name,
|
||||
year: this.year,
|
||||
order: this.order,
|
||||
...(this.year !== undefined ? { year: this.year } : {}),
|
||||
...(this.order !== undefined ? { order: this.order } : {}),
|
||||
status: this.status.toString(),
|
||||
startDate: this.startDate,
|
||||
endDate: this.endDate,
|
||||
schedule: this.schedule,
|
||||
scoringConfig: this.scoringConfig,
|
||||
dropPolicy: this.dropPolicy,
|
||||
stewardingConfig: this.stewardingConfig,
|
||||
maxDrivers: this.maxDrivers,
|
||||
...(this.startDate !== undefined ? { startDate: this.startDate } : {}),
|
||||
...(this.endDate !== undefined ? { endDate: this.endDate } : {}),
|
||||
...(this.schedule !== undefined ? { schedule: this.schedule } : {}),
|
||||
...(this.scoringConfig !== undefined ? { scoringConfig: this.scoringConfig } : {}),
|
||||
...(this.dropPolicy !== undefined ? { dropPolicy: this.dropPolicy } : {}),
|
||||
...(this.stewardingConfig !== undefined ? { stewardingConfig: this.stewardingConfig } : {}),
|
||||
...(this.maxDrivers !== undefined ? { maxDrivers: this.maxDrivers } : {}),
|
||||
participantCount: newCount.toNumber(),
|
||||
});
|
||||
}
|
||||
@@ -573,16 +600,16 @@ export class Season implements IEntity<string> {
|
||||
leagueId: this.leagueId,
|
||||
gameId: this.gameId,
|
||||
name: this.name,
|
||||
year: this.year,
|
||||
order: this.order,
|
||||
...(this.year !== undefined ? { year: this.year } : {}),
|
||||
...(this.order !== undefined ? { order: this.order } : {}),
|
||||
status: this.status.toString(),
|
||||
startDate: this.startDate,
|
||||
endDate: this.endDate,
|
||||
schedule: this.schedule,
|
||||
scoringConfig: this.scoringConfig,
|
||||
dropPolicy: this.dropPolicy,
|
||||
stewardingConfig: this.stewardingConfig,
|
||||
maxDrivers: this.maxDrivers,
|
||||
...(this.startDate !== undefined ? { startDate: this.startDate } : {}),
|
||||
...(this.endDate !== undefined ? { endDate: this.endDate } : {}),
|
||||
...(this.schedule !== undefined ? { schedule: this.schedule } : {}),
|
||||
...(this.scoringConfig !== undefined ? { scoringConfig: this.scoringConfig } : {}),
|
||||
...(this.dropPolicy !== undefined ? { dropPolicy: this.dropPolicy } : {}),
|
||||
...(this.stewardingConfig !== undefined ? { stewardingConfig: this.stewardingConfig } : {}),
|
||||
...(this.maxDrivers !== undefined ? { maxDrivers: this.maxDrivers } : {}),
|
||||
participantCount: newCount.toNumber(),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user