-
Notifications
You must be signed in to change notification settings - Fork 12k
fix: Return empty available days if error querying calendar #22828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
0e5d487
9d25488
80e5c8f
5e25ac9
4c3688c
40fa281
aea0f56
8664277
3038e21
69c087f
aa1842b
8ea3465
59e1276
4cef0e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -179,13 +179,24 @@ const _getBusyTimes = async (params: { | |
| performance.measure(`prisma booking get took $1'`, "prismaBookingGetStart", "prismaBookingGetEnd"); | ||
| if (credentials?.length > 0 && !bypassBusyCalendarTimes) { | ||
| const startConnectedCalendarsGet = performance.now(); | ||
| const calendarBusyTimes = await getBusyCalendarTimes( | ||
|
|
||
| const calendarBusyTimesQuery = await getBusyCalendarTimes( | ||
| credentials, | ||
| startTime, | ||
| endTime, | ||
| selectedCalendars, | ||
| shouldServeCache | ||
| ); | ||
|
|
||
| if (!calendarBusyTimesQuery.success) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We throw an error when failing to get the calendar event times because it's not a true representation of a user's busy times. |
||
| throw new Error( | ||
| `Failed to fetch busy calendar times for selected calendars ${selectedCalendars.map( | ||
| (calendar) => calendar.id | ||
| )}` | ||
| ); | ||
| } | ||
|
|
||
| const calendarBusyTimes = calendarBusyTimesQuery.data; | ||
| const endConnectedCalendarsGet = performance.now(); | ||
| logger.debug( | ||
| `Connected Calendars get took ${ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -411,24 +411,39 @@ const _getUserAvailability = async function getUsersWorkingHoursLifeTheUniverseA | |
| ? EventTypeRepository.getSelectedCalendarsFromUser({ user, eventTypeId: eventType.id }) | ||
| : user.userLevelSelectedCalendars; | ||
|
|
||
| const busyTimes = await getBusyTimes({ | ||
| credentials: user.credentials, | ||
| startTime: getBusyTimesStart, | ||
| endTime: getBusyTimesEnd, | ||
| eventTypeId, | ||
| userId: user.id, | ||
| userEmail: user.email, | ||
| username: `${user.username}`, | ||
| beforeEventBuffer, | ||
| afterEventBuffer, | ||
| selectedCalendars, | ||
| seatedEvent: !!eventType?.seatsPerTimeSlot, | ||
| rescheduleUid: initialData?.rescheduleUid || null, | ||
| duration, | ||
| currentBookings: initialData?.currentBookings, | ||
| bypassBusyCalendarTimes, | ||
| shouldServeCache, | ||
| }); | ||
| let busyTimes = []; | ||
| try { | ||
| busyTimes = await getBusyTimes({ | ||
| credentials: user.credentials, | ||
| startTime: getBusyTimesStart, | ||
| endTime: getBusyTimesEnd, | ||
| eventTypeId, | ||
| userId: user.id, | ||
| userEmail: user.email, | ||
| username: `${user.username}`, | ||
| beforeEventBuffer, | ||
| afterEventBuffer, | ||
| selectedCalendars, | ||
| seatedEvent: !!eventType?.seatsPerTimeSlot, | ||
| rescheduleUid: initialData?.rescheduleUid || null, | ||
| duration, | ||
| currentBookings: initialData?.currentBookings, | ||
| bypassBusyCalendarTimes, | ||
| shouldServeCache, | ||
| }); | ||
| } catch (error) { | ||
| log.error(`Error fetching busy times for user ${username}:`, error); | ||
| return { | ||
| busy: [], | ||
| timeZone, | ||
| dateRanges: [], | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there is an error getting busy times, then return an array with no available days. |
||
| oooExcludedDateRanges: [], | ||
| workingHours: [], | ||
| dateOverrides: [], | ||
| currentSeats: [], | ||
| datesOutOfOffice: undefined, | ||
| }; | ||
| } | ||
|
|
||
| const detailedBusyTimes: EventBusyDetails[] = [ | ||
| ...busyTimes.map((a) => ({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the
startDateandendDateout of thetryblock so it can be accessed inside of thecatchblock