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

* don't filter if reschedule with same host

* check for reschedule

* fix filtering in handleNewBooking

* fix type error

---------

Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
Carina WollendorferandCarinaWolli authored and GitHub committed 2024-11-21 01:22:43 +00:00
1 parent ade144aa20
commit 8bc2c08288
4 files changed
+24 -14

No files matched your search

+15 -12
View File
@@ -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;