Skip to content

Tournament match · Repositories

1 module · 15 exports · 1 repository · 0 e2e tests · 2 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.

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

type

FindMatchById

no JSDoc:56
export type FindMatchById = NonNullable<Unwrapped<typeof findMatchById>>;
interface

AllMatchResult

no JSDoc:265
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;
		}>;
	}>;
}
type

FindByTournamentTeamIdItem

no JSDoc:480
export type FindByTournamentTeamIdItem = Unwrapped<
	typeof findByTournamentTeamId
>;

Functions & values

function

findAllByChatRoomIds

:27

Matches owning the given chat rooms, with the tournament they belong to.

export async function findAllByChatRoomIds(chatRoomIds: number[])
function

findResultById

no JSDoc:127
export function findResultById(id: number)
function

insertResult

:171

Inserts a single game result, returning the id it was given.

export function insertResult(
	args: Insertable<DB["TournamentMatchGameResult"]>,
	trx?: Transaction<DB>,
)
function

updateResultKo

:183

Updates the KO status of a single game result.

export function updateResultKo(
	args: { id: number; ko: boolean },
	trx?: Transaction<DB>,
)
function

setParticipants

:195

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

deleteResultById

:228

Deletes a single game result by its id.

export function deleteResultById(id: number, trx?: Transaction<DB>)
function

deletePickBanEventsByMatchId

:236

Deletes all pick/ban events belonging to a match.

export function deletePickBanEventsByMatchId(
	matchId: number,
	trx?: Transaction<DB>,
)
function

deletePickBanEvent

:247

Deletes a single pick/ban event by its match and event number.

export function deletePickBanEvent(
	args: { matchId: number; number: number },
	trx?: Transaction<DB>,
)
function

findAllResultsByTournamentId

no JSDoc:282
export async function findAllResultsByTournamentId(
	tournamentId: number,
): Promise<AllMatchResult[]>
function

findUserParticipationByTournamentId

no JSDoc:451
export async function findUserParticipationByTournamentId(
	tournamentId: number,
)
function

findScheduleProposalsByMatchId

:602

Open candidate times of the set's scheduling board, earliest first, with who put them up.

export function findScheduleProposalsByMatchId(matchId: number)
function

findLastResultAtsByTournamentId

:619

Per match of the tournament, when its last game was reported.

export function findLastResultAtsByTournamentId(tournamentId: number)
function

findScheduledByUserIds

:646

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

findScheduledByUserId

:671

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

findScheduledBetween

:714

Undecided league sets agreed to be played inside the window, with both rosters.

export function findScheduledBetween({
	startsAt,
	endsAt,
}: {
	startsAt: number;
	endsAt: number;
})
Unit tests (1)
function

insertScheduleProposals

:773

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

replaceScheduleProposals

:800

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

findScheduleProposalById

no JSDoc:847
export function findScheduleProposalById(id: number)
function

deleteScheduleProposalsByTeam

:856

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;
})
Unit tests (1)
function

scheduleMatch

:877

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