BroadcastRepository
app/features/broadcast/BroadcastRepository.server.ts- Tables
- CalendarEventTournamentTournamentBroadcastTournamentTeamMemberUnvalidatedUserSubmittedImageUserUserBroadcastProgramUserSubmittedImageUserWeaponPool
- Calls
- ChatRepository
- Imports
- Producer
- Used by
- 2 loaders1 action3 modules1 script3 other
Functions & values
Producer state, settings and chat room of the channel's broadcast, undefined before anything was written to it.
export function findByChannel({ tournamentId, channel }: BroadcastKey)
Broadcasts owning the given chat rooms, with their tournament's cast accounts to find the channel by.
export async function findAllByChatRoomIds(chatRoomIds: number[])
Members of the teams with their top weapons (favorites first, then the pool's order), owner first then in joining order.
export function findAllPlayersByTournamentTeamIds(tournamentTeamIds: number[])
Sets the producer state's fields that apply as soon as set, leaving the rest of it as it is.
export async function updateState({ patch, ...key }: WriteArgs & { patch: Partial<Pick<BroadcastStoredState, "liveResults" | "ink">>; })
Unit tests (1)
Replaces the producer state with what change makes of it, read and written in one transaction so changes made at the same time (e.g. two producers, or an automatic Take) don't overwrite each other. change returning null leaves the state as it is. Returns whether it was changed.
export function updateProducer<Item extends ProducerState>({ change, ...key }: WriteArgs<Item> & { change: ( state: BroadcastStoredState<Item>, ) => BroadcastStoredState<Item> | null; })
Unit tests (3)
Sets the given settings, leaving the others as they are (the theme and the show info are saved by separate forms).
export async function updateSettings< Settings extends BroadcastSettings = BroadcastSettings, >({ patch, ...key }: WriteArgs & { patch: Partial<Settings> })
Unit tests (1)
The OBS URL of the program key: whose and which channel's it is and the broadcast it shows, undefined for an unknown key.
export function findProgramByKey(programKey: string)
The user's OBS URL for the channel: its key and the broadcast it shows with its tournament's name (nulls before it is pointed at one). undefined before the user generated it.
export function findProgram({ userId, channel, }: { userId: number; channel: BroadcastKey["channel"]; })
Channels whose OBS URL of the user shows one of the tournament's broadcasts.
export function findProgramChannelsByTournament({ userId, tournamentId, }: { userId: number; tournamentId: number; })
Points the user's OBS URL for the channel at the channel's broadcast in the tournament, creating the URL (with a new random key) or the broadcast when missing. Returns the URL's id and key.
export function pointProgram({ userId, ...key }: WriteArgs & { userId: number; })
Gives the user's OBS URL for the channel a new random key, replacing the one it had. Returns the URL's id and new key, undefined without a URL.
export function refreshProgramKey({ userId, channel, }: { userId: number; channel: BroadcastKey["channel"]; })
Gives the channel's broadcast its chat room, creating the broadcast too when nothing was written to it yet. Returns the room's id and whether it was created now.
export function insertChatRoomIfMissing({ expiresAt, ...key }: WriteArgs & { expiresAt: Date })