-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
feat: Round Robin Weights #15558
feat: Round Robin Weights #15558
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
E2E results are ready! |
packages/features/eventtypes/components/AddMembersWithSwitch.tsx
Outdated
Show resolved
Hide resolved
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 would've liked to see more test cases, but we can add them after; looks good from my end 🚀
@@ -23,10 +39,11 @@ async function leastRecentlyBookedUser<T extends Pick<User, "id" | "email">>({ | |||
createdAt: true, | |||
}, | |||
where: { | |||
eventTypeId, | |||
eventTypeId: eventType.id, | |||
status: BookingStatus.ACCEPTED, |
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.
Sounds sensible! Yeah happy with that.
What does this PR do?
Adds weights to round robin alogirthm. When weights are enabled each host has 100% as the default weight. That means that ideally, all hosts end up with the same amount of bookings. If weights are enabled, priorities are only taken into account when more than one host is selected by the
getUsersBasedOnWeights
function.To make sure that adding new host, when other hosts already have bookings doesn't result in the new host being assigned to all bookings we use weightAdjustments.
WeightAdjustment (nr of 'fake' bookings)
= ((nr of all bookings of current RR hosts
+sum of all weight adjustments of current RR hosts
) /sum of all current RR hosts weights
) *new host's weight
Weights enabled:
Weights disabled:
Set weight:
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?