Skip to content

Scheduling infrastructure for absolutely everyone.

fix: no availability on reschedule with load balancing (#17770)

Carina Wollendorfer8bc2c08288d4
diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts
index 717b5a06750..48582a4fe57 100644
--- a/packages/features/bookings/lib/handleNewBooking.ts
+++ b/packages/features/bookings/lib/handleNewBooking.ts
@@ -477,6 +477,7 @@ async function handler(
logger: loggerWithEventDetails,
routedTeamMemberIds: routedTeamMemberIds ?? null,
contactOwnerEmail,
+ isSameHostReschedule: !!(eventType.rescheduleWithSameRoundRobinHost && reqBody.rescheduleUid),
});
// We filter out users but ensure allHostUsers remain same.
diff --git a/packages/features/bookings/lib/handleNewBooking/loadAndValidateUsers.ts b/packages/features/bookings/lib/handleNewBooking/loadAndValidateUsers.ts
index 2a2e6e1a706..aa30587cc8a 100644
--- a/packages/features/bookings/lib/handleNewBooking/loadAndValidateUsers.ts
+++ b/packages/features/bookings/lib/handleNewBooking/loadAndValidateUsers.ts
@@ -42,6 +42,7 @@ type InputProps = {
logger: Logger<unknown>;
routedTeamMemberIds: number[] | null;
contactOwnerEmail: string | null;
+ isSameHostReschedule: boolean;
};
export async function loadAndValidateUsers({
@@ -52,6 +53,7 @@ export async function loadAndValidateUsers({
logger,
routedTeamMemberIds,
contactOwnerEmail,
+ isSameHostReschedule,
}: InputProps): Promise<Users> {
let users: Users = await loadUsers({
eventType,
@@ -110,7 +112,7 @@ export async function loadAndValidateUsers({
email: host.user.email,
user: host.user,
})),
- maxLeadThreshold: eventType.maxLeadThreshold,
+ maxLeadThreshold: isSameHostReschedule ? null : eventType.maxLeadThreshold,
});
if (qualifiedHosts.length) {
// remove users that are not in the qualified hosts array
diff --git a/packages/lib/bookings/findQualifiedHosts.ts b/packages/lib/bookings/findQualifiedHosts.ts
index 300a20db277..d8304bab3ac 100644
--- a/packages/lib/bookings/findQualifiedHosts.ts
+++ b/packages/lib/bookings/findQualifiedHosts.ts
@@ -3,17 +3,19 @@ import type { SchedulingType } from "@calcom/prisma/enums";
import { filterHostsByLeadThreshold } from "./filterHostsByLeadThreshold";
-export const findQualifiedHosts = async <
- T extends { email: string; id: number } & Record<string, unknown>
->(eventType: {
- id: number;
- maxLeadThreshold: number | null;
- hosts?: ({ isFixed: boolean; createdAt: Date; priority?: number | null; weight?: number | null } & {
- user: T;
- })[];
- users: T[];
- schedulingType: SchedulingType | null;
-}): Promise<
+export const findQualifiedHosts = async <T extends { email: string; id: number } & Record<string, unknown>>(
+ eventType: {
+ id: number;
+ maxLeadThreshold: number | null;
+ hosts?: ({ isFixed: boolean; createdAt: Date; priority?: number | null; weight?: number | null } & {
+ user: T;
+ })[];
+ users: T[];
+ schedulingType: SchedulingType | null;
+ rescheduleWithSameRoundRobinHost: boolean;
+ },
+ isReschedule: boolean
+): Promise<
{
isFixed: boolean;
email: string;
@@ -28,7 +30,8 @@ export const findQualifiedHosts = async <
? await filterHostsByLeadThreshold({
eventTypeId: eventType.id,
hosts,
- maxLeadThreshold: eventType.maxLeadThreshold,
+ maxLeadThreshold:
+ isReschedule && eventType.rescheduleWithSameRoundRobinHost ? null : eventType.maxLeadThreshold,
})
: fallbackHosts;
return qualifiedHosts;
diff --git a/packages/trpc/server/routers/viewer/slots/util.ts b/packages/trpc/server/routers/viewer/slots/util.ts
index b615426da8a..2d5f888316e 100644
--- a/packages/trpc/server/routers/viewer/slots/util.ts
+++ b/packages/trpc/server/routers/viewer/slots/util.ts
@@ -479,7 +479,11 @@ async function _getAvailableSlots({ input, ctx }: GetScheduleOptions): Promise<I
throw new TRPCError({ message: "Invalid time range given.", code: "BAD_REQUEST" });
}
- const eventHosts = await monitorCallbackAsync(findQualifiedHosts<GetAvailabilityUser>, eventType);
+ const eventHosts = await monitorCallbackAsync(
+ findQualifiedHosts<GetAvailabilityUser>,
+ eventType,
+ !!input.rescheduleUid
+ );
const hostsAfterSegmentMatching = await findMatchingHostsWithEventSegment({
eventType,
normalizedHosts: eventHosts,