refactor: convert getBusyTimes to service class with dependency injection#22949
Merged
ThyMinimalDev merged 9 commits intomainfrom Aug 8, 2025
Merged
Conversation
…tion - Create BusyTimesService following UserAvailabilityService pattern - Add DI tokens, module, and container setup for BusyTimesService - Update all usage locations to use service instead of direct function calls - Maintain existing function signatures for backward compatibility - Add legacy exports to ensure smooth transition - Update type references in trpc util to use service prototype - Fix linting issues by making legacy exports async with proper imports - All tests pass and type checking succeeds Co-Authored-By: morgan@cal.com <morgan@cal.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (08/08/25)1 reviewer was added to this PR based on Keith Williams's automation. |
Contributor
E2E results are ready! |
ThyMinimalDev
approved these changes
Aug 8, 2025
pallava-joshi
pushed a commit
to pallava-joshi/cal.com
that referenced
this pull request
Aug 8, 2025
…tion (calcom#22949) * refactor: convert getBusyTimes to service class with dependency injection - Create BusyTimesService following UserAvailabilityService pattern - Add DI tokens, module, and container setup for BusyTimesService - Update all usage locations to use service instead of direct function calls - Maintain existing function signatures for backward compatibility - Add legacy exports to ensure smooth transition - Update type references in trpc util to use service prototype - Fix linting issues by making legacy exports async with proper imports - All tests pass and type checking succeeds Co-Authored-By: morgan@cal.com <morgan@cal.com> * refactor: busy time service * fix: api v2 eslint plugins version mismatch * chore: bump platform libs * chore: bump platform libs * fix: missing di busyTimesModule in slots service --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: morgan@cal.com <morgan@cal.com> Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
refactor: convert getBusyTimes to service class with dependency injection
Summary
This PR refactors the
packages/lib/getBusyTimes.tsfile from standalone functions to a service class using dependency injection, following the same pattern asUserAvailabilityService. The refactoring includes:BusyTimesServiceclass with dependency injection forBookingRepositoryThe main functions (
getBusyTimes,getBusyTimesForLimitChecks,getStartEndDateforLimitCheck) are now methods on the service class, with the same signatures and behavior preserved.Review & Testing Checklist for Human
getBusyTimes,getBusyTimesForLimitChecks, orgetStartEndDateforLimitCheckstill workgetStartEndDateforLimitCheckasync doesn't break any calling code that expected synchronous behaviorRecommended test plan: Create a test booking through the UI, verify availability slots are shown correctly, and confirm busy times are properly calculated during the booking process.
Diagram
%%{ init : { "theme" : "default" }}%% graph TD subgraph "DI Infrastructure" tokens["packages/lib/di/tokens.ts"]:::minor-edit module["packages/lib/di/modules/busy-times.ts"]:::major-edit container["packages/lib/di/containers/busy-times.ts"]:::major-edit end subgraph "Core Service" getBusyTimes["packages/lib/getBusyTimes.ts<br/>BusyTimesService class"]:::major-edit bookingRepo["BookingRepository"]:::context end subgraph "Usage Locations" userAvail["packages/lib/getUserAvailability.ts"]:::minor-edit slotsUtil["packages/trpc/server/routers/viewer/slots/util.ts"]:::minor-edit ensureUsers["packages/features/bookings/lib/handleNewBooking/ensureAvailableUsers.ts"]:::minor-edit limitsServer["packages/lib/intervalLimits/server/getBusyTimesFromLimits.ts"]:::minor-edit end container --> getBusyTimes module --> container tokens --> module getBusyTimes --> bookingRepo userAvail --> container slotsUtil --> container ensureUsers --> container limitsServer --> container subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
UserAvailabilityServicefor consistencygetStartEndDateforLimitCheckfunction was made async to resolve ESLint linting issues with require statements