Fix/office365 api call (#3534)
* WIP fixes for handling office365 api call * First working version microsoft api call handling * Remove logs * Clean up and improve function names * Clean up * Remove log * Fix function missing its correct name * Fix direct return of statement * Cleanup * Simplify with private fetcher * Update CalendarService.ts * Update getOfficeAppKeys.ts Co-authored-by: zomars <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
9 files changed
+271
-109
No files matched your search
@@ -100,11 +100,12 @@ const getCachedResults = async (
|
||||
const passedSelectedCalendars = selectedCalendars.filter((sc) => sc.integration === type);
|
||||
/** We extract external Ids so we don't cache too much */
|
||||
const selectedCalendarIds = passedSelectedCalendars.map((sc) => sc.externalId);
|
||||
/** We create a unque hash key based on the input data */
|
||||
/** We create a unique hash key based on the input data */
|
||||
const cacheKey = JSON.stringify({ id, selectedCalendarIds, dateFrom, dateTo });
|
||||
const cacheHashedKey = createHash("md5").update(cacheKey).digest("hex");
|
||||
/** Check if we already have cached data and return */
|
||||
const cachedAvailability = cache.get(cacheHashedKey);
|
||||
|
||||
if (cachedAvailability) {
|
||||
log.debug(`Cache HIT: Calendar Availability for key: ${cacheKey}`);
|
||||
return cachedAvailability;
|
||||
@@ -113,6 +114,7 @@ const getCachedResults = async (
|
||||
/** If we don't then we actually fetch external calendars (which can be very slow) */
|
||||
const availability = await c.getAvailability(dateFrom, dateTo, passedSelectedCalendars);
|
||||
/** We save the availability to a few seconds so recurrent calls are nearly instant */
|
||||
|
||||
cache.put(cacheHashedKey, availability, CACHING_TIME);
|
||||
return availability;
|
||||
});
|
||||
|
||||
@@ -47,7 +47,7 @@ export async function getBusyTimes(params: {
|
||||
logger.debug(`prisma booking get took ${endPrismaBookingGet - startPrismaBookingGet}ms`);
|
||||
if (credentials.length > 0) {
|
||||
const calendarBusyTimes = await getBusyCalendarTimes(credentials, startTime, endTime, selectedCalendars);
|
||||
// console.log("calendarBusyTimes", calendarBusyTimes);
|
||||
|
||||
busyTimes.push(...calendarBusyTimes); /*
|
||||
// TODO: Disabled until we can filter Zoom events by date. Also this is adding too much latency.
|
||||
const videoBusyTimes = (await getBusyVideoTimes(credentials)).filter(notEmpty);
|
||||
|
||||
@@ -151,6 +151,7 @@ export async function getUserAvailability(
|
||||
);
|
||||
const endGetWorkingHours = performance.now();
|
||||
logger.debug(`getWorkingHours took ${endGetWorkingHours - startGetWorkingHours}ms for userId ${userId}`);
|
||||
|
||||
return {
|
||||
busy: bufferedBusyTimes,
|
||||
timeZone,
|
||||
|
||||
Reference in new issue
Block a user