Skip to content

Tournament bracket · Repositories

11 modules · 98 exports · 2 repositories · 35 e2e tests · 3 routes

Every table a function queries, its own helpers included, read or written. Calls to other repositories are listed apart, their tables are on their own page.

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

function

findByTournamentId

:29

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>
Unit tests (2)
function

insertBracket

:142

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 }>
function

applyMatchChanges

:260

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.

  • @returns

    ids of the chat rooms whose inactive flag changed, to notify participants of after commit

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)
function

insertRoundMatches

:477

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>
function

deleteRoundMatches

:525

DELETEs a round's matches (swiss unadvance).

export async function deleteRoundMatches(args: {
	stageId: number;
	groupId: number;
	roundId: number;
}): Promise<void>
function

resetBracket

:539

Deletes the whole stage subtree (matches, rounds, groups, stage).

export function resetBracket(tournamentStageId: number)
Unit tests (1)
Unit tests not about one export (4)

TournamentMatchVodRepository

app/features/tournament-bracket/TournamentMatchVodRepository.server.ts
Tables
CalendarEventCalendarEventDateTournamentTournamentGroupTournamentMatchTournamentMatchGameResultTournamentMatchGameResultParticipantTournamentMatchVodTournamentRoundTournamentStageTournamentStreamerTournamentTeamTournamentTeamMemberUserUserSubmittedImage
Calls
no other repositories
Imports
no other modules
Used by
1 loader1 component2 routines2 scripts

Types

type

VodsByTournamentId

no JSDoc:13
export type VodsByTournamentId = Awaited<
	ReturnType<typeof findVodsByTournamentId>
>;

Functions & values

function

findVodsByTournamentId

no JSDoc:16
export function findVodsByTournamentId(tournamentId: number)
function

findAllForDownloadByTournamentId

:71

Every VoD of the tournament with what is needed to download its match: its round, when the match started and when its last game was reported, plus the streamer and the team whose POV the VoD is and how many sets that team won (null for casts).

export async function findAllForDownloadByTournamentId(tournamentId: number)
function

insertMany

no JSDoc:170
export function insertMany(vods: Omit<Tables["TournamentMatchVod"], "id">[])
function

findTournamentsNeedingVodSync

no JSDoc:184
export function findTournamentsNeedingVodSync()
function

markVodSyncCompleted

no JSDoc:215
export function markVodSyncCompleted(tournamentId: number)
function

findStreamersByTournamentId

no JSDoc:259
export function findStreamersByTournamentId(tournamentId: number)
function

findCastedMatchHistoryByTournamentId

no JSDoc:317
export async function findCastedMatchHistoryByTournamentId(
	tournamentId: number,
)