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.
- Tables
- CalendarEventMapPoolMapScrimMapListTournament
- Calls
- ScrimMapRepository
- Imports
- TeamPick
- Used by
- 1 loader1 action1 repository1 script
Types
typeResolvedScrimMapList
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
functionsubmitMapListAndGenerateIfNeeded
: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)
Deletes a side's map list, if one exists.
export async function deleteMapList(
scrimPostId: number,
side: ScrimSide,
): Promise<void>
functionfindMapListsByScrimPostId
: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)
- Tables
- ScrimMap
- Calls
- ScrimMapListRepository
- Imports
- ScrimScrimMapByMap
- Used by
- 1 loader1 action1 repository1 script
Functions & values
functionreportMapAndGenerateNext
: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>
functionundoMostRecentMap
: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>
functionreplaceCurrentMap
: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>
functionfindMapsByScrimPostId
:91 Returns the scrim's maps ordered by index ascending.
export function findMapsByScrimPostId(scrimPostId: number)
functiontryGenerateAndInsertNextMap
: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>
- Tables
- ScrimPickupRosterScrimPickupRosterUserUserUserSubmittedImage
- Calls
- no other repositories
- Imports
- no other modules
- Used by
- 1 loader1 action1 routine
Functions & values
functionfindAllOwnRecent
:10 Pick-up rosters recently used by the logged in user, newest first.
export function findAllOwnRecent()
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[])
Deletes pick-up rosters that have not been used within the expiry window.
export function deleteOld()
Unit tests not about one export (6)
- Tables
- CalendarEventScrimPostScrimPostRequestScrimPostRequestUserScrimPostUserTeamUnvalidatedUserSubmittedImageUserUserSubmittedImage
- Calls
- ChatRepository
- Imports
- Scrim
- Used by
- 3 loaders3 actions1 module1 routine1 script3 other
Types
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
functioninsert
no JSDoc:52 export function insert(args: InsertArgs)
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)
functiondeleteById
no JSDoc:140 export function deleteById(scrimPostId: number)
Unit tests (1)
functionfindAllByChatRoomIds
:365 Posts owning the given chat rooms, with the users of the post and of its accepted request.
export async function findAllByChatRoomIds(chatRoomIds: number[])
functionfindById
no JSDoc:406 export async function findById(scrimPostId: number): Promise<ScrimPost | null>
functionfindAllRelevant
no JSDoc:417 export async function findAllRelevant(): Promise<ScrimPost[]>
functionacceptRequest
no JSDoc:434 export function acceptRequest(scrimPostRequestId: number)
Unit tests (2)
functiondeleteRequest
no JSDoc:493 export function deleteRequest(scrimPostRequestId: number)
functioncancelScrim
no JSDoc:500 export function cancelScrim(id: number, reason: string)
Unit tests (1)
functionfindAcceptedScrimsBetweenTwoTimestamps
: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)
functionfindAllAcceptedByUserIds
: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;
})functionfindPendingOverlapsForUsers
: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)
functionfindUserScrims
no JSDoc:704 export async function findUserScrims(userId: number): Promise<SidebarScrim[]>
Unit tests (4)