perf: Remove organisation as it's unused in getBusyTimes (?) (#10619)

Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
Alex van AndelandKeith Williams authored and GitHub committed 2023-08-07 10:06:48 -04:00
1 parent df674532a4
commit 2f23b5de9b
4 files changed
+14 -47

No files matched your search

+1 -2
View File
@@ -198,8 +198,7 @@ export const getBusyCalendarTimes = async (
withCredentials: CredentialPayload[],
dateFrom: string,
dateTo: string,
selectedCalendars: SelectedCalendar[],
organizationSlug?: string | null
selectedCalendars: SelectedCalendar[]
) => {
let results: EventBusyDate[][] = [];
const months = getMonths(dateFrom, dateTo);
+1 -4
View File
@@ -14,7 +14,6 @@ export async function getBusyTimes(params: {
credentials: Credential[];
userId: number;
username: string;
organizationSlug?: string | null | undefined;
eventTypeId?: number;
startTime: string;
beforeEventBuffer?: number;
@@ -30,7 +29,6 @@ export async function getBusyTimes(params: {
eventTypeId,
startTime,
endTime,
organizationSlug,
beforeEventBuffer,
afterEventBuffer,
selectedCalendars,
@@ -165,8 +163,7 @@ export async function getBusyTimes(params: {
credentials,
startTime,
endTime,
selectedCalendars,
organizationSlug
selectedCalendars
);
const endConnectedCalendarsGet = performance.now();
logger.debug(
+2 -20
View File
@@ -29,7 +29,6 @@ const availabilitySchema = z
beforeEventBuffer: z.number().optional(),
duration: z.number().optional(),
withSource: z.boolean().optional(),
orgSlug: z.string().optional(),
})
.refine((data) => !!data.username || !!data.userId, "Either username or userId should be filled in.");
@@ -77,11 +76,6 @@ const getUser = (where: Prisma.UserWhereInput) =>
select: {
...availabilityUserSelect,
credentials: true,
organization: {
select: {
slug: true,
},
},
},
});
@@ -122,7 +116,6 @@ export async function getUserAvailability(
afterEventBuffer?: number;
beforeEventBuffer?: number;
duration?: number;
orgSlug?: string;
},
initialData?: {
user?: User;
@@ -130,17 +123,8 @@ export async function getUserAvailability(
currentSeats?: CurrentSeats;
}
) {
const {
username,
userId,
dateFrom,
dateTo,
eventTypeId,
afterEventBuffer,
beforeEventBuffer,
duration,
orgSlug,
} = availabilitySchema.parse(query);
const { username, userId, dateFrom, dateTo, eventTypeId, afterEventBuffer, beforeEventBuffer, duration } =
availabilitySchema.parse(query);
if (!dateFrom.isValid() || !dateTo.isValid()) {
throw new HttpError({ statusCode: 400, message: "Invalid time range given." });
@@ -148,7 +132,6 @@ export async function getUserAvailability(
const where: Prisma.UserWhereInput = {};
if (username) where.username = username;
if (orgSlug) where.organization = { slug: orgSlug };
if (userId) where.id = userId;
const user = initialData?.user || (await getUser(where));
@@ -172,7 +155,6 @@ export async function getUserAvailability(
eventTypeId,
userId: user.id,
username: `${user.username}`,
organizationSlug: initialData?.user?.organization?.slug,
beforeEventBuffer,
afterEventBuffer,
selectedCalendars: user.selectedCalendars,