Skip to content

Scrims · Repositories

2 modules · 22 exports · 4 repositories · 12 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.

ScrimMapListRepository

app/features/scrims/ScrimMapListRepository.server.ts
Tables
CalendarEventMapPoolMapScrimMapListTournament
Calls
ScrimMapRepository
Imports
TeamPick
Used by
1 loader1 action1 repository1 script

Types

type

ResolvedScrimMapList

no JSDoc:59
export type ResolvedScrimMapList = {
	side: ScrimSide;
	mapList: Array<{ mode: ModeShort; stageId: StageId }>;
	tournament?: { id: number; name: string };
	updatedAt: number;
};
Only used inside the module

Functions & values

function

submitMapListAndGenerateIfNeeded

:17

Upserts the side's map list row and, atomically, inserts the scrim's next map if no unreported one is waiting.

export async function submitMapListAndGenerateIfNeeded(
	args: SubmitMapListArgs,
): Promise<void>
Unit tests (1)
function

deleteMapList

:48

Deletes a side's map list, if one exists.

export async function deleteMapList(
	scrimPostId: number,
	side: ScrimSide,
): Promise<void>
function

findMapListsByScrimPostId

:67

The scrim's submitted map lists with pools resolved to (mode, stageId) pairs; tournament-sourced rows carry the tournament's id and name.

export async function findMapListsByScrimPostId(
	scrimPostId: number,
	trx?: Transaction<DB>,
): Promise<ResolvedScrimMapList[]>
Unit tests (1)

ScrimMapRepository

app/features/scrims/ScrimMapRepository.server.ts
Tables
ScrimMap
Calls
ScrimMapListRepository
Imports
ScrimScrimMapByMap
Used by
1 loader1 action1 repository1 script

Functions & values

function

reportMapAndGenerateNext

:18

Marks a map as reported with the winner side and, atomically, inserts the next map if no unreported one is waiting.

export async function reportMapAndGenerateNext(
	args: ReportMapArgs,
): Promise<void>
function

undoMostRecentMap

:38

Reverses the most recent report: deletes the unreported next slot (if any) and clears winner/reportedAt on the last reported map.

export async function undoMostRecentMap(scrimPostId: number): Promise<void>
TablesScrimMap
function

replaceCurrentMap

:76

Replaces the scrim's unreported map with the given mode/stage, keeping its index ("replay previous map" and "pick a map").

export async function replaceCurrentMap(
	args: ReplaceCurrentMapArgs,
): Promise<void>
TablesScrimMap
function

findMapsByScrimPostId

:91

Returns the scrim's maps ordered by index ascending.

export function findMapsByScrimPostId(scrimPostId: number)
TablesScrimMap
function

tryGenerateAndInsertNextMap

:101

Inserts the next map when a pool derives from the submitted lists and no unreported map waits. Runs in the caller's transaction so two concurrent actions can't insert the same index.

export async function tryGenerateAndInsertNextMap(
	scrimPostId: number,
	trx: Transaction<DB>,
): Promise<void>

ScrimPickupRosterRepository

app/features/scrims/ScrimPickupRosterRepository.server.ts
Tables
ScrimPickupRosterScrimPickupRosterUserUserUserSubmittedImage
Calls
no other repositories
Imports
no other modules
Used by
1 loader1 action1 routine

Functions & values

function

findAllOwnRecent

:10

Pick-up rosters recently used by the logged in user, newest first.

export function findAllOwnRecent()
function

upsertOwn

:35

Marks the roster as the user's most recently used pick-up, reusing a saved one with the same members and pruning the ones that fall out. @returns id of the inserted or reused roster

export function upsertOwn(memberUserIds: number[])
function

deleteOld

:109

Deletes pick-up rosters that have not been used within the expiry window.

export function deleteOld()
Unit tests not about one export (6)

ScrimPostRepository

app/features/scrims/ScrimPostRepository.server.ts
Tables
CalendarEventScrimPostScrimPostRequestScrimPostRequestUserScrimPostUserTeamUnvalidatedUserSubmittedImageUserUserSubmittedImage
Calls
ChatRepository
Imports
Scrim
Used by
3 loaders3 actions1 module1 routine1 script3 other

Types

type

SidebarScrim

no JSDoc:694
export type SidebarScrim = {
	id: number;
	startsAt: number;
	opponentName: string | null;
	opponentAvatarUrl: string | null;
	/** Owner of an opponent without a team, whose avatar stands in for a team's logo. */
	opponentUser: CommonUser | null;
	status: "booked" | "looking" | "requestPending";
};

Functions & values

function

insert

no JSDoc:52
export function insert(args: InsertArgs)
function

insertRequest

:95

Inserts a request to a scrim post, returning its id. @throws {DuplicateEntryError} if the team already has one for the post.

export function insertRequest(args: InsertRequestArgs)
Unit tests (2)
function

deleteById

no JSDoc:140
export function deleteById(scrimPostId: number)
TablesScrimPost
Unit tests (1)
Actions/scrims
function

findAllByChatRoomIds

:365

Posts owning the given chat rooms, with the users of the post and of its accepted request.

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

findById

no JSDoc:406
export async function findById(scrimPostId: number): Promise<ScrimPost | null>
function

findAllRelevant

no JSDoc:417
export async function findAllRelevant(): Promise<ScrimPost[]>
function

deleteRequest

no JSDoc:493
export function deleteRequest(scrimPostRequestId: number)
Actions/scrims
function

cancelScrim

no JSDoc:500
export function cancelScrim(id: number, reason: string)
Unit tests (1)
function

findAcceptedScrimsBetweenTwoTimestamps

:529

Accepted scrims starting within [startTime, endTime), excluding ones created after excludeRecentlyCreated.

export async function findAcceptedScrimsBetweenTwoTimestamps({
	startTime,
	endTime,
	excludeRecentlyCreated,
}: {
	startTime: Date;
	endTime: Date;
	excludeRecentlyCreated: Date;
})
Unit tests (2)
function

findAllAcceptedByUserIds

:553

Accepted, uncanceled scrims of the users whose resolved start (accepted request's time for a range post, else the post's) falls in the window; one row per participating user per scrim.

export async function findAllAcceptedByUserIds({
	userIds,
	startsAt,
	endsAt,
}: {
	userIds: Array<number>;
	startsAt: number;
	endsAt: number;
})
function

findPendingOverlapsForUsers

:602

Pending (unaccepted, uncanceled, future) posts and requests involving the users that overlap [startTime, endTime], for auto-cleaning when a scrim is scheduled: posts come with member ids for notifying, requests are deleted silently.

export async function findPendingOverlapsForUsers({
	userIds,
	startTime,
	endTime,
	excludePostId,
}: {
	userIds: number[];
	/** window start, database timestamp (seconds) */
	startTime: number;
	/** window end, database timestamp (seconds) */
	endTime: number;
	excludePostId: number;
}): Promise<{
	posts: Array<{ id: number; startsAt: number; memberIds: number[] }>;
	requestIds: number[];
}>
Unit tests (8)