BracketRepository
app/features/tournament-bracket/BracketRepository.server.ts- Tables
- TournamentGroupTournamentMatchTournamentRoundTournamentStageTournamentTeam
- Calls
- ChatRepository
- Imports
- no other modules
- Used by
- 3 actions1 module1 script2 other
Functions & values
Full BracketData of all stages, with score/totalKos aggregated over TournamentMatchGameResult. Also called inside write transactions: propagation needs fresh rows, not the cached Tournament.
export async function findByTournamentId( tournamentId: number, trx?: Transaction<DB>, ): Promise<BracketData>
Persists Engine.create output, translating local ids to row ids. Stage number follows the existing stages.
export function insertBracket(args: { tournamentId: number; name: string; bracket: BracketData; /** League rounds are all playable from the start, so their chat rooms live longer unless the stage is real-time. */ isLeague: boolean; }): Promise<{ stageId: number }>
UPDATEs the changed matches' opponents and syncs startedAt with the implied statuses. Called inside the caller's transaction with the bracket data the operation was computed from.
export async function applyMatchChanges( args: { previousData: BracketData; result: EngineResult; /** League rounds are all playable from the start, so their chat rooms live longer unless the stage is real-time. */ isLeague: boolean; }, trx: Transaction<DB>, ): Promise<number[]>
Unit tests (3)
INSERTs a generated round's matches (swiss advance).
export async function insertRoundMatches( args: { stageId: number; round: GeneratedRound; /** The teams schedule the sets (league), so their chat rooms live longer. */ hasScheduling: boolean; }, trx?: Transaction<DB>, ): Promise<void>
DELETEs a round's matches (swiss unadvance).
export async function deleteRoundMatches(args: { stageId: number; groupId: number; roundId: number; }): Promise<void>
Deletes the whole stage subtree (matches, rounds, groups, stage).
export function resetBracket(tournamentStageId: number)