cal.com
cal.com copied to clipboard
feat: to enable optimized slots
What does this PR do?
- Fixes #16575
- Fixes CAL-4303
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)
- [x] I have self-reviewed the code (A decent size PR without self-review might be rejected).
- [x] -N/A - I have added a Docs issue here if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
- [x] I confirm automated tests are in place that prove my fix is effective or that my feature works.
@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.
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.
This availability:
@CarinaWolli , handled this edge case. Also added a test case for this.
To explain the implementation - A increment is added to the slotStartTime to adjust to be Start Of the hour, if this increment exceeds the next Start of the hour, a condition is added to Not exceed the Start of the hour. This should cover all cases.
This PR is being marked as stale due to inactivity.
resolved merge conflicts. Gentle reminder!
Moving to draft since there a bunch of conflicts
@keithwillcode, resolved conflicts and all tests are passing 🙏
Resolved merge conflicts again, tests are passing, hence making ready for review. 🙏
@vijayraghav-io let's fix the conflicts
@vijayraghav-io let's fix the conflicts
sure will do
@anikdhabal , all tests are passing 🙏 removed all unrelated changes
@anikdhabal , Gentle Reminder 🙏
@vijayraghav-io the pr still has merge conflicts. Can you please try to fix them. Marking this draft for now.
sure, had resolved conflicts earlier, these must be latest one, will resolve and update!
@Devanshusharma2005 , resolved merge conflicts.
I found one issue, everything else looked good 🙏
@CarinaWolli , fixed 🙏 , also added a test case.
still seeing an issue with slots, see my comment below
This should fix, please check my reply https://github.com/calcom/cal.com/pull/16579#discussion_r2200598196
This is working great now. Thanks for applying my feedback so quickly 🙏 It still needs review from @calcom/platform @calcom/dba. In the meantime, can you look into fixing the merge conflicts?
Thank you! for confirming 🙏 , sure will fix the merge conflicts.
Walkthrough
Adds an end-to-end "showOptimizedSlots" feature: database migration and Prisma schema field, repository selects, default values and test builders, threading the flag into server slot retrieval, extending getSlots/buildSlots signatures with a new helper to adjust initial slot start times, unit tests validating optimized-slot behavior, a UI toggle and English localization entries.
Assessment against linked issues
| Objective | Addressed | Explanation |
|---|---|---|
| Add a setting to enable optimized schedules; generate optimal slots while prioritizing clean start times when possible [#16575, CAL-4303] | ✅ |
Out-of-scope changes
| Code Change | Explanation |
|---|---|
| Add NEXT_PUBLIC_AVAILABILITY_SCHEDULE_INTERVAL to globalEnv (turbo.json) | This CI/env declaration is unrelated to the optimized schedules feature; no objective referenced environment/global tooling changes. |
Possibly related PRs
- calcom/cal.com#22787 — touches the same available-slots retrieval flow (packages/trpc/server/routers/viewer/slots/util.ts) where
showOptimizedSlotsis now passed intogetSlots, indicating a code-level overlap.
📜 Recent review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📥 Commits
Reviewing files that changed from the base of the PR and between 00918d6ef2cb1ac863f383db841d1e6a3e12e587 and 12b8c0c0e08671a5f1b1bc4f788f8180c8c8e289.
📒 Files selected for processing (2)
packages/lib/slots.ts(6 hunks)turbo.json(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- turbo.json
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/lib/slots.ts
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Install dependencies / Yarn install & cache
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. - PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
CodeRabbit Commands (Invoked using PR/Issue comments)
Type @coderabbitai help to get the list of available commands.
Other keywords and placeholders
- Add
@coderabbitai ignoreor@coderabbit ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
Status, Documentation and Community
- Visit our Status Page to check the current availability of CodeRabbit.
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
✅ No security or compliance issues detected. Reviewed everything up to 7accaf7d0174aacc2e7cbd7fe07998c2bc388b02.
Security Overview
- 🔎 Scanned files: 16 changed file(s)
Detected Code Changes
The diff is too large to display a summary of code changes.
Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.
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 🙏
Reminding.....
/tip 100 @vijayraghav-io
🎉🎈 @vijayraghav-io has been awarded $100 by Cal.com, Inc.! 🎈🎊
resolved merge conflicts
Thanks @vijayraghav-io. @emrysal is currently reviewing/testing.