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:
1 parent
ade144aa20
commit
8bc2c08288
4 files changed
+24
-14
No files matched your search
@@ -477,6 +477,7 @@ async function handler(
|
|||||||
logger: loggerWithEventDetails,
|
logger: loggerWithEventDetails,
|
||||||
routedTeamMemberIds: routedTeamMemberIds ?? null,
|
routedTeamMemberIds: routedTeamMemberIds ?? null,
|
||||||
contactOwnerEmail,
|
contactOwnerEmail,
|
||||||
|
isSameHostReschedule: !!(eventType.rescheduleWithSameRoundRobinHost && reqBody.rescheduleUid),
|
||||||
});
|
});
|
||||||
|
|
||||||
// We filter out users but ensure allHostUsers remain same.
|
// We filter out users but ensure allHostUsers remain same.
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ type InputProps = {
|
|||||||
logger: Logger<unknown>;
|
logger: Logger<unknown>;
|
||||||
routedTeamMemberIds: number[] | null;
|
routedTeamMemberIds: number[] | null;
|
||||||
contactOwnerEmail: string | null;
|
contactOwnerEmail: string | null;
|
||||||
|
isSameHostReschedule: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export async function loadAndValidateUsers({
|
export async function loadAndValidateUsers({
|
||||||
@@ -52,6 +53,7 @@ export async function loadAndValidateUsers({
|
|||||||
logger,
|
logger,
|
||||||
routedTeamMemberIds,
|
routedTeamMemberIds,
|
||||||
contactOwnerEmail,
|
contactOwnerEmail,
|
||||||
|
isSameHostReschedule,
|
||||||
}: InputProps): Promise<Users> {
|
}: InputProps): Promise<Users> {
|
||||||
let users: Users = await loadUsers({
|
let users: Users = await loadUsers({
|
||||||
eventType,
|
eventType,
|
||||||
@@ -110,7 +112,7 @@ export async function loadAndValidateUsers({
|
|||||||
email: host.user.email,
|
email: host.user.email,
|
||||||
user: host.user,
|
user: host.user,
|
||||||
})),
|
})),
|
||||||
maxLeadThreshold: eventType.maxLeadThreshold,
|
maxLeadThreshold: isSameHostReschedule ? null : eventType.maxLeadThreshold,
|
||||||
});
|
});
|
||||||
if (qualifiedHosts.length) {
|
if (qualifiedHosts.length) {
|
||||||
// remove users that are not in the qualified hosts array
|
// 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";
|
import { filterHostsByLeadThreshold } from "./filterHostsByLeadThreshold";
|
||||||
|
|
||||||
export const findQualifiedHosts = async <
|
export const findQualifiedHosts = async <T extends { email: string; id: number } & Record<string, unknown>>(
|
||||||
T extends { email: string; id: number } & Record<string, unknown>
|
eventType: {
|
||||||
>(eventType: {
|
id: number;
|
||||||
id: number;
|
maxLeadThreshold: number | null;
|
||||||
maxLeadThreshold: number | null;
|
hosts?: ({ isFixed: boolean; createdAt: Date; priority?: number | null; weight?: number | null } & {
|
||||||
hosts?: ({ isFixed: boolean; createdAt: Date; priority?: number | null; weight?: number | null } & {
|
user: T;
|
||||||
user: T;
|
})[];
|
||||||
})[];
|
users: T[];
|
||||||
users: T[];
|
schedulingType: SchedulingType | null;
|
||||||
schedulingType: SchedulingType | null;
|
rescheduleWithSameRoundRobinHost: boolean;
|
||||||
}): Promise<
|
},
|
||||||
|
isReschedule: boolean
|
||||||
|
): Promise<
|
||||||
{
|
{
|
||||||
isFixed: boolean;
|
isFixed: boolean;
|
||||||
email: string;
|
email: string;
|
||||||
@@ -28,7 +30,8 @@ export const findQualifiedHosts = async <
|
|||||||
? await filterHostsByLeadThreshold({
|
? await filterHostsByLeadThreshold({
|
||||||
eventTypeId: eventType.id,
|
eventTypeId: eventType.id,
|
||||||
hosts,
|
hosts,
|
||||||
maxLeadThreshold: eventType.maxLeadThreshold,
|
maxLeadThreshold:
|
||||||
|
isReschedule && eventType.rescheduleWithSameRoundRobinHost ? null : eventType.maxLeadThreshold,
|
||||||
})
|
})
|
||||||
: fallbackHosts;
|
: fallbackHosts;
|
||||||
return qualifiedHosts;
|
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" });
|
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({
|
const hostsAfterSegmentMatching = await findMatchingHostsWithEventSegment({
|
||||||
eventType,
|
eventType,
|
||||||
normalizedHosts: eventHosts,
|
normalizedHosts: eventHosts,
|
||||||
|
|||||||
Reference in new issue
Block a user