-
Notifications
You must be signed in to change notification settings - Fork 10.3k
feat: to enable optimized slots #16579
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
base: main
Are you sure you want to change the base?
feat: to enable optimized slots #16579
Conversation
@vijayraghav-io is attempting to deploy a commit to the cal Team on Vercel. A member of the Team first needs to authorize it. |
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (09/10/24)1 reviewer was added to this PR based on Keith Williams's automation. "Add community label" took an action on this PR • (09/10/24)1 label was added to this PR based on Keith Williams's automation. "Add foundation team as reviewer" took an action on this PR • (09/12/24)1 reviewer was added to this PR based on Keith Williams's automation. |
packages/lib/slots.ts
Outdated
slotStartTime = | ||
slotStartTime.minute() % interval !== 0 | ||
? showOptimizedSlots | ||
? slotStartTime.add(rangeEnd.diff(slotStartTime, "minutes") % interval, "minute") |
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.
This ensures within a time range, always maximum available (optimum) slots are shown (without loss of any slot) And also Start of the Hour is respected.
Also , this happens only if user availability starts in minutes , say 10:10 , 10:05 (instead of 10:00 normally) and user has chosen to optimize.
For all other scenarios, the existing behaviour applies and i understand that is expected.
E2E results are ready! |
…6575_optimizedSchedules
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.
Thanks for the PR @vijayraghav-io 🙌.
Haven't tested it completely yet, but code wise looks good. Can you add tests to ensure this works and won't break in the future.
Thank you! @Amit91848 , sure will add tests. |
@Amit91848, added tests. |
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.
@CarinaWolli , handled this edge case. Also added a test case for this. To explain the implementation - |
packages/lib/slots.ts
Outdated
? rangeEnd.diff(slotStartTime, "minutes") % interval > interval - slotStartTime.minute() | ||
? slotStartTime.add(interval - slotStartTime.minute(), "minute") | ||
: slotStartTime.add(rangeEnd.diff(slotStartTime, "minutes") % interval, "minute") |
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.
rangeEnd.diff(slotStartTime, "minutes") % interval
- gives the remaining grace minutes available for adjustment, after consuming maximum possible slots.
Condition rangeEnd.diff(slotStartTime, "minutes") % interval > interval - slotStartTime.minute()
-
After adding this grace (or free) minutes available for adjustment to slotStartTime
, if result exceeds the 'next start of the hour , it is adjusted to 'start of the hour
✅ No security or compliance issues detected. Reviewed everything up to 7accaf7. Security Overview
Detected Code ChangesThe diff is too large to display a summary of code changes. Reply to this PR with |
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.
Great pr @vijayraghav-io . Can you please address the typecheck issue failing.
Thank you! 🙏 , sure will address. |
@Devanshusharma2005 all checks are passing |
@emrysal for review, it's looking good from my side 🙏 |
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.
LGTM
What does this PR do?
For the sake of demo video, availability is adjusted to simulate busy time as per examples in issue description. It should work same even with calendar busy times.
https://www.loom.com/share/8247ea087bae4aa497c48853bb2e3f8d?sid=33a96f51-1548-43d7-9b37-815d90ecc6b8
Video with calendar busy times (as per example)
https://www.loom.com/share/a9a04ee012134f31b4a5a0dfa6b2072e?sid=a4a98b11-263d-4799-875e-fe46b45ab8bf
Mandatory Tasks (DO NOT REMOVE)