TournamentMatchRepository
app/features/tournament-match/TournamentMatchRepository.server.ts- Tables
- CalendarEventTournamentTournamentGroupTournamentMatchTournamentMatchGameResultTournamentMatchGameResultParticipantTournamentMatchPickBanEventTournamentMatchScheduleProposalTournamentRoundTournamentStageTournamentTeamTournamentTeamMemberUnvalidatedUserSubmittedImageUserUserSubmittedImage
- Calls
- no other repositories
- Imports
- no other modules
- Used by
- 5 loaders1 action1 route1 module1 routine1 script10 other
Types
export type FindMatchById = NonNullable<Unwrapped<typeof findMatchById>>;
export interface AllMatchResult { opponentOne: AllMatchResultOpponent; opponentTwo: AllMatchResultOpponent; winnerSide: Side; roundMaps: TournamentRoundMaps; maps: Array<{ stageId: StageId; mode: ModeShort; winnerTeamId: number; participants: Array<{ // nullable in the DB, but always a number for new tournaments tournamentTeamId: number; userId: number; }>; }>; }
export type FindByTournamentTeamIdItem = Unwrapped< typeof findByTournamentTeamId >;
Functions & values
Matches owning the given chat rooms, with the tournament they belong to.
export async function findAllByChatRoomIds(chatRoomIds: number[])
export async function findMatchById(id: number)
export function findResultById(id: number)
export function findResultsByMatchId(matchId: number)
Inserts a single game result, returning the id it was given.
export function insertResult( args: Insertable<DB["TournamentMatchGameResult"]>, trx?: Transaction<DB>, )
Updates the KO status of a single game result.
export function updateResultKo( args: { id: number; ko: boolean }, trx?: Transaction<DB>, )
Sets the players who participated in a game result, replacing any existing ones.
export async function setParticipants( args: { resultId: number; participants: Array< Pick< Insertable<DB["TournamentMatchGameResultParticipant"]>, "userId" | "tournamentTeamId" > >; }, trx: Transaction<DB>, )
Deletes a single game result by its id.
export function deleteResultById(id: number, trx?: Transaction<DB>)
Deletes all pick/ban events belonging to a match.
export function deletePickBanEventsByMatchId( matchId: number, trx?: Transaction<DB>, )
Deletes a single pick/ban event by its match and event number.
export function deletePickBanEvent( args: { matchId: number; number: number }, trx?: Transaction<DB>, )
export async function findAllResultsByTournamentId( tournamentId: number, ): Promise<AllMatchResult[]>
export async function findUserParticipationByTournamentId( tournamentId: number, )
export function findByTournamentTeamId(tournamentTeamId: number)
Unit tests (2)
Open candidate times of the set's scheduling board, earliest first, with who put them up.
export function findScheduleProposalsByMatchId(matchId: number)
Per match of the tournament, when its last game was reported.
export function findLastResultAtsByTournamentId(tournamentId: number)
Undecided league sets of the users' teams agreed to be played inside the window, one row per member; the blocks their schedules show.
export function findScheduledByUserIds({ userIds, startsAt, endsAt, }: { userIds: Array<number>; startsAt: number; endsAt: number; })
Undecided league sets of the user's teams agreed to be played inside the window, for the sidebar's events.
export function findScheduledByUserId({ userId, startsAt, endsAt, }: { userId: number; startsAt: number; endsAt: number; })
Undecided league sets agreed to be played inside the window, with both rosters.
export function findScheduledBetween({ startsAt, endsAt, }: { startsAt: number; endsAt: number; })
Puts the candidate times on the set's board; ones the team already has there are skipped.
export function insertScheduleProposals({ matchId, tournamentTeamId, authorId, proposedAts, }: { matchId: number; tournamentTeamId: number; authorId: number; proposedAts: Array<number>; })
Makes proposedAts the team's candidates on the set's board: missing ones are added, ones not listed are taken off. Returns the added rows.
export function replaceScheduleProposals({ matchId, tournamentTeamId, authorId, proposedAts, }: { matchId: number; tournamentTeamId: number; authorId: number; proposedAts: Array<number>; })
Unit tests (2)
export function findScheduleProposalById(id: number)
Takes one team's candidates off the board, e.g. when the other team declines a reschedule. Returns the count deleted.
export async function deleteScheduleProposalsByTeam({ matchId, tournamentTeamId, }: { matchId: number; tournamentTeamId: number; })
Agrees the set's time, clearing the board; setByOrganizer closes the board for the teams.
export function scheduleMatch({ matchId, scheduledAt, setByOrganizer, }: { matchId: number; scheduledAt: number; setByOrganizer: boolean; })