Skip to content

fix(bookings): duration limit of seated booking makes available seats unavailable to book#28448

Open
bandhan-majumder wants to merge 2 commits intocalcom:mainfrom
bandhan-majumder:fix-13509
Open

fix(bookings): duration limit of seated booking makes available seats unavailable to book#28448
bandhan-majumder wants to merge 2 commits intocalcom:mainfrom
bandhan-majumder:fix-13509

Conversation

@bandhan-majumder
Copy link
Contributor

What does this PR do?

unblocks same slots with available seats for others to book after the booking duration limit is met. It also sends seating_limit_reached error when slots are full. Users only sees available slots if seats are available.

Visual Demo (For contributors especially)

A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).

Video Demo (if applicable):

Before:

before.mp4

After:

after.mp4

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings
  • My PR is too large (>500 lines or >10 files) and should be split into smaller PRs

@bandhan-majumder bandhan-majumder requested a review from a team as a code owner March 15, 2026 16:31
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Mar 15, 2026
@github-actions github-actions bot added foundation High priority Created by Linear-GitHub Sync seats area: seats, guest meetings, multiple people labels Mar 15, 2026
@bandhan-majumder bandhan-majumder changed the title fix(bookings): duration limit reach with available seats fix(bookings): duration limit of seated booking makes available seats unavailable to book Mar 15, 2026
@graphite-app
Copy link

graphite-app bot commented Mar 15, 2026

Graphite Automations

"Send notification to Community team when High Priority PR opened" took an action on this PR • (03/15/26)

2 teammates were notified to this PR based on Keith Williams's automation.

const bookingRepo = new BookingRepository(prisma);

// seated events with more than 1 seat, check if the user is joining an existing slot
if (seatsPerTimeSlot && seatsPerTimeSlot > 1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 seat available slots are kind of same like normal bookings with no offer seats. So, the logic to group seats to a single booking while counting total duration is implemented here when seats are more than 1

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 issues found across 9 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/features/bookings/lib/checkDurationLimits.ts">

<violation number="1" location="packages/features/bookings/lib/checkDurationLimits.ts:81">
P2: New seat-limit errors are thrown as 403 but immediately remapped to 401, so the intended capacity status is not propagated.</violation>
</file>

<file name="packages/trpc/server/routers/viewer/slots/util.ts">

<violation number="1" location="packages/trpc/server/routers/viewer/slots/util.ts:487">
P2: Seat-aware duration handling was added only for PER_YEAR; PER_DAY/PER_WEEK/PER_MONTH still sum each seated booking row and can overcount duration, causing premature busy limits.</violation>
</file>

<file name="packages/features/bookings/repositories/BookingRepository.test.ts">

<violation number="1" location="packages/features/bookings/repositories/BookingRepository.test.ts:68">
P2: New duration-limit tests are assertion-light: they only validate mocked totals, not seat-aware/reschedule SQL branch behavior.</violation>
</file>

<file name="packages/features/availability/lib/getUserAvailability.ts">

<violation number="1" location="packages/features/availability/lib/getUserAvailability.ts:649">
P2: Duration-limit seat restoration updates only `dateRanges`, leaving `oooExcludedDateRanges` stale and causing booking checks that rely on `oooExcludedDateRanges` to still reject restored slots.</violation>

<violation number="2" location="packages/features/availability/lib/getUserAvailability.ts:672">
P2: Seat-based availability restoration ignores the requested duration override and always restores using `eventType.length`, which can produce incorrect availability ranges for custom-duration requests.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.


if (totalBookingDuration < limitingNumber) return;
if (slotStatus.exists) {
if (slotStatus.isSeatFull) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when someone tries to book a seated booking even though seat is full via api (UI won\t show). This is for a safety check.

// seated events durations are calculated based on unique time slots, not individual bookings
// seatsPerTimeSlot >= 1 indicates a seated event
// but having a single seat or seatsPerTimeSlot == 1, is same as calculating based on individual bookings
const shouldGroupSeatsAsSingleBooking = seatsPerTimeSlot !== null && seatsPerTimeSlot !== undefined && seatsPerTimeSlot > 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as this comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Created by Linear-GitHub Sync foundation High priority Created by Linear-GitHub Sync seats area: seats, guest meetings, multiple people size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-3099] Issue with "Limit total booking duration" and offering seats.

1 participant