Added a span for all users' bookings

perf/get-schedule-with-tracing^2
Keith Williams 2023-09-12 13:54:12 -03:00
parent f9ea62ae2d
commit 3273876fd3
2 changed files with 6 additions and 0 deletions

View File

@ -141,6 +141,8 @@ export async function getBusyTimes(params: {
}, },
}); });
getBookingsSpan.end();
const bookingSeatCountMap: { [x: string]: number } = {}; const bookingSeatCountMap: { [x: string]: number } = {};
const busyTimes = bookings.reduce( const busyTimes = bookings.reduce(
(aggregate: EventBusyDetails[], { id, startTime, endTime, eventType, title, ...rest }) => { (aggregate: EventBusyDetails[], { id, startTime, endTime, eventType, title, ...rest }) => {

View File

@ -306,6 +306,8 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions) {
}, },
}; };
const getBookingsSpan = tracer.startSpan("getBookingsAllUsers", undefined, context.active());
const currentBookingsAllUsers = await prisma.booking.findMany({ const currentBookingsAllUsers = await prisma.booking.findMany({
where: { where: {
OR: [ OR: [
@ -355,6 +357,8 @@ export async function getAvailableSlots({ input, ctx }: GetScheduleOptions) {
}, },
}); });
getBookingsSpan.end();
/* We get all users working hours and busy slots */ /* We get all users working hours and busy slots */
const userAvailability = await Promise.all( const userAvailability = await Promise.all(
usersWithCredentials.map(async (currentUser) => { usersWithCredentials.map(async (currentUser) => {