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

@@ -114,26 +114,16 @@ export async function getEventType(input: TGetScheduleInputSchema) {
isFixed: true,
user: {
select: {
credentials: true, // Don't leak credentials to the client
credentials: true,
...availabilityUserSelect,
organization: {
select: {
slug: true,
},
},
},
},
},
},
users: {
select: {
credentials: true, // Don't leak credentials to the client
credentials: true,
...availabilityUserSelect,
organization: {
select: {
slug: true,
},
},
},
},
},
@@ -165,13 +155,8 @@ export async function getDynamicEventType(input: TGetScheduleInputSchema) {
},
select: {
allowDynamicBooking: true,
credentials: true, // Don't leak credentials to the client
...availabilityUserSelect,
organization: {
select: {
slug: true,
},
},
credentials: true,
},
});
const isDynamicAllowed = !users.some((user) => !user.allowDynamicBooking);
@@ -234,6 +219,7 @@ export async function getAvailableSlots(input: TGetScheduleInputSchema) {
if (eventType.schedulingType && !!eventType.hosts?.length) {
usersWithCredentials = eventType.hosts.map(({ isFixed, user }) => ({ isFixed, ...user }));
}
/* We get all users working hours and busy slots */
const userAvailability = await Promise.all(
usersWithCredentials.map(async (currentUser) => {
@@ -255,7 +241,11 @@ export async function getAvailableSlots(input: TGetScheduleInputSchema) {
beforeEventBuffer: eventType.beforeEventBuffer,
duration: input.duration || 0,
},
{ user: currentUser, eventType, currentSeats }
{
user: currentUser,
eventType,
currentSeats,
}
);
if (!currentSeats && _currentSeats) currentSeats = _currentSeats;
return {
@@ -432,8 +422,7 @@ export async function getAvailableSlots(input: TGetScheduleInputSchema) {
users: (eventType.hosts
? eventType.hosts.map((hostUserWithCredentials) => {
const { user } = hostUserWithCredentials;
const { credentials: _credentials, ...hostUser } = user;
return hostUser;
return user;
})
: eventType.users
).map((user) => user.username || ""),