perf: Move query to get just the user email to the main get query (#11230)
This commit is contained in:
parent
3132c64205
commit
4ef52aa2c6
|
@ -13,6 +13,7 @@ import type { EventBusyDetails } from "@calcom/types/Calendar";
|
||||||
export async function getBusyTimes(params: {
|
export async function getBusyTimes(params: {
|
||||||
credentials: Credential[];
|
credentials: Credential[];
|
||||||
userId: number;
|
userId: number;
|
||||||
|
userEmail: string;
|
||||||
username: string;
|
username: string;
|
||||||
eventTypeId?: number;
|
eventTypeId?: number;
|
||||||
startTime: string;
|
startTime: string;
|
||||||
|
@ -27,6 +28,7 @@ export async function getBusyTimes(params: {
|
||||||
const {
|
const {
|
||||||
credentials,
|
credentials,
|
||||||
userId,
|
userId,
|
||||||
|
userEmail,
|
||||||
username,
|
username,
|
||||||
eventTypeId,
|
eventTypeId,
|
||||||
startTime,
|
startTime,
|
||||||
|
@ -45,15 +47,6 @@ export async function getBusyTimes(params: {
|
||||||
status: BookingStatus.ACCEPTED,
|
status: BookingStatus.ACCEPTED,
|
||||||
})}`
|
})}`
|
||||||
);
|
);
|
||||||
// get user email for attendee checking.
|
|
||||||
const user = await prisma.user.findUniqueOrThrow({
|
|
||||||
where: {
|
|
||||||
id: userId,
|
|
||||||
},
|
|
||||||
select: {
|
|
||||||
email: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A user is considered busy within a given time period if there
|
* A user is considered busy within a given time period if there
|
||||||
|
@ -97,7 +90,7 @@ export async function getBusyTimes(params: {
|
||||||
...sharedQuery,
|
...sharedQuery,
|
||||||
attendees: {
|
attendees: {
|
||||||
some: {
|
some: {
|
||||||
email: user.email,
|
email: userEmail,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -180,6 +180,7 @@ export const getUserAvailability = async function getUsersWorkingHoursLifeTheUni
|
||||||
endTime: getBusyTimesEnd,
|
endTime: getBusyTimesEnd,
|
||||||
eventTypeId,
|
eventTypeId,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
userEmail: user.email,
|
||||||
username: `${user.username}`,
|
username: `${user.username}`,
|
||||||
beforeEventBuffer,
|
beforeEventBuffer,
|
||||||
afterEventBuffer,
|
afterEventBuffer,
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { Prisma } from "@prisma/client";
|
||||||
export const availabilityUserSelect = Prisma.validator<Prisma.UserSelect>()({
|
export const availabilityUserSelect = Prisma.validator<Prisma.UserSelect>()({
|
||||||
id: true,
|
id: true,
|
||||||
timeZone: true,
|
timeZone: true,
|
||||||
|
email: true,
|
||||||
bufferTime: true,
|
bufferTime: true,
|
||||||
startTime: true,
|
startTime: true,
|
||||||
username: true,
|
username: true,
|
||||||
|
@ -22,7 +23,6 @@ export const availabilityUserSelect = Prisma.validator<Prisma.UserSelect>()({
|
||||||
});
|
});
|
||||||
|
|
||||||
export const baseUserSelect = Prisma.validator<Prisma.UserSelect>()({
|
export const baseUserSelect = Prisma.validator<Prisma.UserSelect>()({
|
||||||
email: true,
|
|
||||||
name: true,
|
name: true,
|
||||||
destinationCalendar: true,
|
destinationCalendar: true,
|
||||||
locale: true,
|
locale: true,
|
||||||
|
@ -35,7 +35,6 @@ export const baseUserSelect = Prisma.validator<Prisma.UserSelect>()({
|
||||||
|
|
||||||
export const userSelect = Prisma.validator<Prisma.UserArgs>()({
|
export const userSelect = Prisma.validator<Prisma.UserArgs>()({
|
||||||
select: {
|
select: {
|
||||||
email: true,
|
|
||||||
name: true,
|
name: true,
|
||||||
allowDynamicBooking: true,
|
allowDynamicBooking: true,
|
||||||
destinationCalendar: true,
|
destinationCalendar: true,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user