Skip to content

Commit 36ebaa9

Browse files
committed
fix(guest-availability): use overlap semantics for busy time query
The previous condition (startTime >= windowStart AND endTime <= windowEnd) only matched bookings fully contained within the search window. Bookings that straddle a boundary — e.g. a guest booking that starts before the rescheduling window begins but ends inside it — were silently dropped, leaving a gap in conflict detection. Fix: switch to standard interval-overlap semantics: startTime < windowEnd AND endTime > windowStart This correctly captures every booking whose time range intersects the window, regardless of whether it extends beyond either edge. Addresses P2 feedback from cubic review of PR #28164.
1 parent 6ccf3bf commit 36ebaa9

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

packages/features/bookings/repositories/BookingRepository.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,8 +2193,12 @@ export class BookingRepository implements IBookingRepository {
21932193
return this.prismaClient.booking.findMany({
21942194
where: {
21952195
status: BookingStatus.ACCEPTED,
2196-
startTime: { gte: startDate },
2197-
endTime: { lte: endDate },
2196+
// Use overlap semantics: any booking whose time range intersects [startDate, endDate].
2197+
// A booking overlaps the window when it starts before the window ends AND ends after
2198+
// the window starts. The previous condition (gte/lte) missed bookings that straddle
2199+
// a window boundary (e.g. started before startDate but ends inside the window).
2200+
startTime: { lt: endDate },
2201+
endTime: { gt: startDate },
21982202
...(excludedUid ? { uid: { not: excludedUid } } : {}),
21992203
attendees: {
22002204
some: {

0 commit comments

Comments
 (0)