From 8a6a7524cc8786127e2517eeba1feea07f27e8ec Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Fri, 24 Feb 2023 01:22:18 +0000 Subject: [PATCH] Prioritise organizer to be the fixed, not lucky (round robin) user (#7317) --- packages/features/bookings/lib/handleNewBooking.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts index cda99effe4..5a86c0b448 100644 --- a/packages/features/bookings/lib/handleNewBooking.ts +++ b/packages/features/bookings/lib/handleNewBooking.ts @@ -474,7 +474,8 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) { ) { throw new Error("Some users are unavailable for booking."); } - users = [...luckyUsers, ...availableUsers.filter((user) => user.isFixed)]; + // Pushing fixed user before the luckyUser guarantees the (first) fixed user as the organizer. + users = [...availableUsers.filter((user) => user.isFixed), ...luckyUsers]; } const rainbowAppData = getEventTypeAppData(eventType, "rainbow") || {};