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
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)
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)
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)
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)
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; })
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)
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)
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)
Deletes weeks started before the timestamp; slots and day notes cascade.
export function deleteWeeksStartedBefore(weekStartsAt: number)
Unit tests (1)
Deletes team events that ended before the given timestamp.
export function deleteTeamEventsEndedBefore(endsAt: number)
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>; })
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)
export function deleteTeamEvent(id: number)