-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fairness when routing #18550
base: main
Are you sure you want to change the base?
fix: Fairness when routing #18550
Conversation
@@ -27,18 +26,10 @@ afterEach(() => { | |||
}); | |||
|
|||
describe("filterHostByLeadThreshold", () => { | |||
it("skips filter if host is fixed", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed users are now type guarded.
it("skips filter if lead threshold is null", async () => { | ||
const hosts = [{ isFixed: false, createdAt: new Date(), user: { id: 1 } }]; | ||
const hosts = [ | ||
{ isFixed: false as const, createdAt: new Date(), user: { id: 1, email: "[email protected]" } }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to mark isFixed as const so it's not type hinted boolean
- passing a boolean type errors.
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
if (contactOwnerEmail && aggregatedAvailability.length > 0) { | ||
// Fairness and Contact Owner disqualification reasons need Availability within 2 weeks | ||
// if not, we attempt to re-open. | ||
if (fallbackHosts && fallbackHosts.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joeauyeung rewritten this check, now any time there's fallbackHosts found I run the 2-weeks check; if there's not enough availability within the qualified users we use the fallbackHosts instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure we want that?
If reschedule with same host is enabled, we would do that too then. I think we shouldn't make that change in this PR
@@ -886,29 +875,6 @@ const calculateHostsAndAvailabilities = async ({ | |||
bypassBusyCalendarTimes: boolean; | |||
shouldServeCache?: boolean; | |||
}) => { | |||
const routedTeamMemberIds = input.routedTeamMemberIds ?? null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to filterHostsBySameRoundRobinHost check.
E2E results are ready! |
|
||
return { | ||
qualifiedHosts: [...fixedHosts, ...hostsAfterContactOwnerMatching], | ||
fallbackHosts, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the fallbackHosts should never be the event type hosts.
Fallback hosts should ideally be hostsAfterFairnessMatching
. In case the contact owne has no availability for 2 weeks we would ignore all other logic (attribute routing, fairness,..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this PR do?
Rewrites the handling of pre-qualification due to various filters, correctly and adds fallback logic to whenever no users are returned. We intend to prevent no availability at no cost.
WIP: Pre-push of filters for partial review.