fix: include buffer-overlapping bookings when prefetching bookings for slots#29550
Draft
rxits wants to merge 2 commits into
Draft
fix: include buffer-overlapping bookings when prefetching bookings for slots#29550rxits wants to merge 2 commits into
rxits wants to merge 2 commits into
Conversation
Contributor
|
Welcome to Cal.diy, @rxits! Thanks for opening this pull request. A few things to keep in mind:
A maintainer will review your PR soon. Thanks for contributing! |
|
rxits seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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.
What does this PR do?
Fixes #29532
The slots endpoint can offer a time that booking validation will always reject. When a booking ends just before the requested slot range but its after-event buffer extends into it, the slot listing prefetch misses that booking entirely, so the buffer is never applied and the in-buffer slot shows as available. Picking it then fails with a 500
no_available_users_found_error.The two paths diverge:
getBusyTimes, which widens its bookings query by the largest configurable buffer (getDefinedBufferTimes(), currently 120 min) on both sides, precisely to catch bookings outside the range whose buffers fall inside it.AvailableSlotsServiceviafindAllExistingBookingsForEventTypeBetweenusing the raw requested range, and hands the result togetBusyTimesascurrentBookings— which skips the widened query.This PR applies the same max-buffer widening to the slot-listing prefetch, so both paths see the same bookings. The rest of the busy-time math already handles these bookings correctly once they are in the list (as @jckw noted in the issue, and confirmed by @GAURAV07C's analysis).
How it is tested
Added a
getScheduletest reproducing the issue:Before the fix, the prefetch query (
endTime: { gte: startDate }) excludes the 04:00–04:45 booking and the 05:30 slot is wrongly offered. With the fix it is hidden, matching what booking validation enforces. The test fails onmainand passes with this change.Also ran the full
getSchedule.test.tssuite (37 passed), the slots router tests, andgetBusyTimestests — no regressions. Type checks pass forpackages/trpcandapps/web.Mandatory Tasks (DO NOT REMOVE)