Skip to content

Availability · Repositories

10 modules · 45 exports · 1 repository · 8 e2e tests · 1 route

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.

AvailabilityRepository

app/features/availability/AvailabilityRepository.server.ts
Tables
AvailabilityDayNoteAvailabilitySlotAvailabilityWeekFriendshipTeamTeamEventTeamEventMemberTeamMemberWithSecondaryUserUserSubmittedImage
Calls
no other repositories
Imports
no other modules
Used by
1 loader2 actions3 modules2 routines1 script3 other

Functions & values

function

findScheduleVisibleUserIds

:23

Of userIds, those whose schedule the viewer may see, in the order given. Without the scheduleVisibility preference a schedule is visible to everyone; once set it is an allow-list of friends and teams (secondary memberships count), and the viewer has to be an allowed friend or share one of the allowed teams. The viewer always sees their own.

export async function findScheduleVisibleUserIds({
	userIds,
	viewerId,
}: {
	userIds: Array<number>;
	viewerId: number;
}): Promise<Array<number>>
Unit tests (9)
function

findAllWeeksByUserIds

:93

Reported weeks of the given users overlapping the window, with slots and day notes. A week without slots means "unavailable all week"; no week at all means nothing was reported. Callers pass only ids {@link findScheduleVisibleUserIds} handed back.

export function findAllWeeksByUserIds({
	userIds,
	startsAt,
	endsAt,
}: {
	userIds: Array<number>;
	startsAt: number;
	endsAt: number;
})
Unit tests (2)
function

hasReportedWeek

:145

Whether the user reported the week starting at weekStartsAt. A start within {@link AVAILABILITY.WEEK_MATCH_MAX_DISTANCE_SECONDS} is the same week seen from another timezone.

export async function hasReportedWeek({
	userId,
	weekStartsAt,
}: {
	userId: number;
	weekStartsAt: number;
})
Unit tests (2)
function

findWeekReminderUserIds

:175

Users who have not reported the week starting at weekStartsAt while a teammate has (a reminder is only worth sending then).

export async function findWeekReminderUserIds(weekStartsAt: number)
Unit tests (5)
function

findAllTeamEventsByUserIds

:217

Team events overlapping the window of every team (secondary included) the users are members of, one row per member. Events limited to selected participants only produce rows for those.

export function findAllTeamEventsByUserIds({
	userIds,
	startsAt,
	endsAt,
}: {
	userIds: Array<number>;
	startsAt: number;
	endsAt: number;
})
Unit tests (1)
function

findTeamEventsByTeamId

:265

One team's events overlapping the window, with the participant user ids (empty = the whole team).

export function findTeamEventsByTeamId({
	teamId,
	startsAt,
	endsAt,
}: {
	teamId: number;
	startsAt: number;
	endsAt: number;
})
Unit tests (2)
function

findAllUpcomingTeamEventsByUserId

:301

Ongoing and upcoming events starting within the window of every team (secondary included) the user is a member of, with the owning team. Events limited to selected participants show up only for those. For the user's personal calendar views.

export function findAllUpcomingTeamEventsByUserId({
	userId,
	startsAt,
	endsAt,
}: {
	userId: number;
	startsAt: number;
	endsAt: number;
})
Unit tests (3)
function

findTeamEventById

no JSDoc:348
export function findTeamEventById(id: number)
TablesTeamEvent
function

upsertOwnWeek

:370

Replaces the acting user's week as a whole (slots and day notes left out are removed). A week reported earlier from another timezone (start hours apart, never days) is replaced, not duplicated. Returns the week id.

export function upsertOwnWeek(args: UpsertOwnWeekArgs)
Unit tests (5)
function

deleteWeeksStartedBefore

:451

Deletes weeks started before the timestamp; slots and day notes cascade.

export function deleteWeeksStartedBefore(weekStartsAt: number)
Unit tests (1)
function

deleteTeamEventsEndedBefore

:459

Deletes team events that ended before the given timestamp.

export function deleteTeamEventsEndedBefore(endsAt: number)
TablesTeamEvent
function

insertTeamEvent

:467

Adds a team event authored by the acting user; without participantUserIds the whole team takes part. Returns its id.

export function insertTeamEvent({
	participantUserIds,
	...args
}: Omit<TablesInsertable["TeamEvent"], "authorId"> & {
	participantUserIds?: Array<number>;
})
function

updateTeamEvent

:499

Updates a team event, replacing its participant limitation (none = the whole team takes part).

export function updateTeamEvent({
	id,
	participantUserIds,
	...args
}: {
	id: number;
	name: string;
	startsAt: number;
	endsAt: number;
	participantUserIds?: Array<number>;
})
Unit tests (2)
function

deleteTeamEvent

no JSDoc:533
export function deleteTeamEvent(id: number)
TablesTeamEvent
Unit tests (1)