From 139e47fe3b3cd3a2fa5846651cb9d9946f3ed5f7 Mon Sep 17 00:00:00 2001 From: Eunjae Lee Date: Fri, 31 Oct 2025 11:33:17 +0100 Subject: [PATCH] feat: include EventType.seatsPerTimeSlot in bookings get handler response (#24813) - Add seatsPerTimeSlot field to EventType selection in bookings query - Refactor conditional array pushes to use if statements instead of && operator to fix lint warnings Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- .../server/routers/viewer/bookings/get.handler.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/trpc/server/routers/viewer/bookings/get.handler.ts b/packages/trpc/server/routers/viewer/bookings/get.handler.ts index b52de1681e..caf7e0ab73 100644 --- a/packages/trpc/server/routers/viewer/bookings/get.handler.ts +++ b/packages/trpc/server/routers/viewer/bookings/get.handler.ts @@ -251,7 +251,7 @@ export async function getBookings({ // 4. Scope depends on `user.orgId`: // - If Current user is ORG_OWNER/ADMIN so we get bookings where organization members are attendees // - If Current user is TEAM_OWNER/ADMIN so we get bookings where team members are attendees - userEmailsWhereUserIsAdminOrOwner?.length && + if (userEmailsWhereUserIsAdminOrOwner?.length) { bookingQueries.push({ query: kysely .selectFrom("Booking") @@ -264,10 +264,11 @@ export async function getBookings({ .where("Attendee.email", "in", userEmailsWhereUserIsAdminOrOwner), tables: ["Booking", "Attendee"], }); + } // 5. Scope depends on `user.orgId`: // - If Current user is ORG_OWNER/ADMIN so we get bookings where organization members are attendees via seatsReference // - If Current user is TEAM_OWNER/ADMIN so we get bookings where team members are attendees via seatsReference - userEmailsWhereUserIsAdminOrOwner?.length && + if (userEmailsWhereUserIsAdminOrOwner?.length) { bookingQueries.push({ query: kysely .selectFrom("Booking") @@ -281,11 +282,12 @@ export async function getBookings({ .where("Attendee.email", "in", userEmailsWhereUserIsAdminOrOwner), tables: ["Booking", "Attendee", "BookingSeat"], }); + } // 6. Scope depends on `user.orgId`: // - If Current user is ORG_OWNER/ADMIN, get booking created for an event type within the organization // - If Current user is TEAM_OWNER/ADMIN, get bookings created for an event type within the team - eventTypeIdsWhereUserIsAdminOrOwner?.length && + if (eventTypeIdsWhereUserIsAdminOrOwner?.length) { bookingQueries.push({ query: kysely .selectFrom("Booking") @@ -298,11 +300,12 @@ export async function getBookings({ .where("Booking.eventTypeId", "in", eventTypeIdsWhereUserIsAdminOrOwner), tables: ["Booking", "EventType"], }); + } // 7. Scope depends on `user.orgId`: // - If Current user is ORG_OWNER/ADMIN, get bookings created by users within the same organization // - If Current user is TEAM_OWNER/ADMIN, get bookings created by users within the same organization - userIdsWhereUserIsAdminOrOwner?.length && + if (userIdsWhereUserIsAdminOrOwner?.length) { bookingQueries.push({ query: kysely .selectFrom("Booking") @@ -314,6 +317,7 @@ export async function getBookings({ .where("Booking.userId", "in", userIdsWhereUserIsAdminOrOwner), tables: ["Booking"], }); + } } const queriesWithFilters = bookingQueries.map(({ query, tables }) => { @@ -494,6 +498,7 @@ export async function getBookings({ "EventType.currency", "EventType.metadata", "EventType.disableGuests", + "EventType.seatsPerTimeSlot", "EventType.seatsShowAttendees", "EventType.seatsShowAvailabilityCount", "EventType.eventTypeColor",