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 <wollencarina@gmail.com>
This commit is contained in:
co-authored by
CarinaWolli
parent
ade144aa20
commit
8bc2c08288
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user