perf: Improve loading existing bookings via API (#16410)
This commit is contained in:
1 parent
57e9ef7320
commit
f3462776e8
2 files changed
+76
-66
No files matched your search
@@ -442,7 +442,7 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions): Pro
|
||||
};
|
||||
|
||||
const allUserIds = usersWithCredentials.map((user) => user.id);
|
||||
const bookingsSelect = {
|
||||
const bookingsSelect = Prisma.validator<Prisma.BookingSelect>()({
|
||||
id: true,
|
||||
uid: true,
|
||||
userId: true,
|
||||
@@ -468,7 +468,7 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions): Pro
|
||||
},
|
||||
},
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
const currentBookingsAllUsersQueryOne = prisma.booking.findMany({
|
||||
where: {
|
||||
@@ -477,9 +477,7 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions): Pro
|
||||
in: allUserIds,
|
||||
},
|
||||
},
|
||||
select: {
|
||||
...bookingsSelect,
|
||||
},
|
||||
select: bookingsSelect,
|
||||
});
|
||||
|
||||
const currentBookingsAllUsersQueryTwo = prisma.booking.findMany({
|
||||
@@ -493,9 +491,7 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions): Pro
|
||||
},
|
||||
},
|
||||
},
|
||||
select: {
|
||||
...bookingsSelect,
|
||||
},
|
||||
select: bookingsSelect,
|
||||
});
|
||||
|
||||
const currentBookingsAllUsersQueryThree = prisma.booking.findMany({
|
||||
@@ -511,9 +507,7 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions): Pro
|
||||
in: [BookingStatus.PENDING],
|
||||
},
|
||||
},
|
||||
select: {
|
||||
...bookingsSelect,
|
||||
},
|
||||
select: bookingsSelect,
|
||||
});
|
||||
|
||||
const [resultOne, resultTwo, resultThree] = await Promise.all([
|
||||
|
||||
Reference in new issue
Block a user