Files
calendar/packages/features
Keith WilliamsGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>Alex van Andel
c47b992125 perf: optimize slot conflict checking from O(n²) to O(n log n) (#22101)
* perf: optimize slot conflict checking from O(n²) to O(n log n)

- Replace nested mapping with pre-sorted busy slots for faster lookups
- Use early termination when busy slots are sorted by start time
- Maintain exact same interface and behavior as original checkForConflicts
- All existing tests pass, preserving edge case handling
- Reduces complexity from O(available slots × busy slots) to O(n log n)

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* refactor: move O(n log n) optimization to checkForConflicts function

- Replace inline optimization with optimized checkForConflicts function
- Maintain same performance while improving code architecture
- Avoid duplication of conflict checking logic
- Keep all existing interfaces and behavior unchanged

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* test: add comprehensive unit tests for checkForConflicts function

- Add 20 additional test cases covering edge cases and boundary conditions
- Test multiple busy periods scenarios and complex overlaps
- Comprehensive currentSeats handling scenarios
- Timezone and cross-day boundary testing
- Performance testing with large datasets
- Fix invalid date generation in test data that was causing NaN conflicts
- Achieve near 100% coverage of all conflict scenarios documented in function comments
- Verify behavioral equivalence between original O(n²) and optimized O(n log n) implementations

Co-Authored-By: keith@cal.com <keithwillcode@gmail.com>

* Simple, safe performance tweak

* Explicitly define the input of busy to be either Date or Dayjs, not string

* EventBusyDate must ALWAYS be a type that supports valueOf

* Revert "EventBusyDate must ALWAYS be a type that supports valueOf"

This reverts commit 35b572266219d64c22db3c3e24b0cb6ca7a901a6.

* Revert "Explicitly define the input of busy to be either Date or Dayjs, not string"

This reverts commit 902f29708e4b7990a4e5e2865cab2f18ab3e44f0.

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
2025-06-27 22:10:17 +00:00
..
2025-06-23 08:32:14 +00:00
2025-05-01 07:05:12 +00:00
2022-07-28 13:58:26 -06:00
2022-07-28 13:58:26 -06:00
2025-05-20 15:22:52 +01:00
2025-01-18 16:21:12 -03:00
2025-04-16 15:37:21 +00:00
2025-04-23 15:09:25 +01:00
2022-07-28 13:58:26 -06:00