remove the commented selectedCalendars var, it is not necessary

This commit is contained in:
Efrain Rochin Aramburo 2023-02-09 13:04:26 -07:00
parent b572591259
commit d80f7fb9c3
2 changed files with 10 additions and 23 deletions

View File

@ -16,7 +16,6 @@ export async function getBusyTimes(params: {
beforeEventBuffer?: number;
afterEventBuffer?: number;
endTime: string;
selectedCalendars: SelectedCalendar[];
}) {
const {
credentials,
@ -25,7 +24,6 @@ export async function getBusyTimes(params: {
eventTypeId,
startTime,
endTime,
//selectedCalendars,
beforeEventBuffer,
afterEventBuffer,
} = params;
@ -77,13 +75,7 @@ export async function getBusyTimes(params: {
performance.mark("prismaBookingGetEnd");
performance.measure(`prisma booking get took $1'`, "prismaBookingGetStart", "prismaBookingGetEnd");
if (credentials?.length > 0) {
const calendarBusyTimes = await getBusyCalendarTimes(
username,
credentials,
startTime,
endTime
// selectedCalendars
);
const calendarBusyTimes = await getBusyCalendarTimes(username, credentials, startTime, endTime);
busyTimes.push(
...calendarBusyTimes.map((value) => ({
...value,

View File

@ -121,8 +121,7 @@ export async function getUserAvailability(
if (username) where.username = username;
if (userId) where.id = userId;
let user: User | null = initialData?.user || null;
if (!user) user = await getUser(where);
const user = initialData?.user || (await getUser(where));
if (!user) throw new HttpError({ statusCode: 404, message: "No user found" });
let eventType: EventType | null = initialData?.eventType || null;
@ -137,16 +136,13 @@ export async function getUserAvailability(
const bookingLimits = parseBookingLimit(eventType?.bookingLimits);
const { selectedCalendars, ...currentUser } = user;
const busyTimes = await getBusyTimes({
credentials: currentUser.credentials,
credentials: user.credentials,
startTime: dateFrom.toISOString(),
endTime: dateTo.toISOString(),
eventTypeId,
userId: currentUser.id,
username: `${currentUser.username}`,
selectedCalendars,
userId: user.id,
username: `${user.username}`,
beforeEventBuffer,
afterEventBuffer,
});
@ -223,8 +219,8 @@ export async function getUserAvailability(
}
}
const userSchedule = currentUser.schedules.filter(
(schedule) => !currentUser.defaultScheduleId || schedule.id === currentUser.defaultScheduleId
const userSchedule = user.schedules.filter(
(schedule) => !user?.defaultScheduleId || schedule.id === user?.defaultScheduleId
)[0];
const schedule =
@ -234,17 +230,16 @@ export async function getUserAvailability(
...userSchedule,
availability: userSchedule.availability.map((a) => ({
...a,
userId: currentUser.id,
userId: user.id,
})),
};
const startGetWorkingHours = performance.now();
const timeZone = schedule.timeZone || eventType?.timeZone || currentUser.timeZone;
const timeZone = schedule.timeZone || eventType?.timeZone || user.timeZone;
const availability =
schedule.availability ||
(eventType?.availability.length ? eventType.availability : currentUser.availability);
schedule.availability || (eventType?.availability.length ? eventType.availability : user.availability);
const workingHours = getWorkingHours({ timeZone }, availability);