Skip to content

Commit

Permalink
fix: only allow tournament dates to be scheduled on the hour
Browse files Browse the repository at this point in the history
formalizing an assumption used in the implementation of launch reminders
  • Loading branch information
sgfost committed Jan 25, 2024
1 parent af22f67 commit 8c2f5b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,12 @@ async function createTournamentRoundDate(
tournamentRoundId?: number
): Promise<void> {
const sp = getServices(em);
const scheduledDate = await sp.tournament.createScheduledRoundDate(date, tournamentRoundId);
logger.debug("created scheduled date: %o", scheduledDate);
try {
const scheduledDate = await sp.tournament.createScheduledRoundDate(date, tournamentRoundId);
logger.debug("created scheduled date: %o", scheduledDate);
} catch (e) {
logger.fatal(e as Error);
}
}

function toIntArray(value: string, previous: Array<number>): Array<number> {
Expand Down
3 changes: 3 additions & 0 deletions server/src/services/tournament.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export class TournamentService extends BaseService {
date: Date,
tournamentRoundId?: number
): Promise<TournamentRoundDate> {
if (date.getMinutes() !== 0) {
throw new Error("Only dates on the hour are currently supported");
}
const tournamentRound = await this.getTournamentRound(tournamentRoundId);
const repository = this.em.getRepository(TournamentRoundDate);
const scheduledDate = repository.create({ tournamentRoundId: tournamentRound.id, date });
Expand Down

0 comments on commit 8c2f5b9

Please sign in to comment.