Skip to content

feat: Implement global booking limits for users#14243

Closed
asadath1395 wants to merge 78 commits intocalcom:mainfrom
asadath1395:booking-global-limits
Closed

feat: Implement global booking limits for users#14243
asadath1395 wants to merge 78 commits intocalcom:mainfrom
asadath1395:booking-global-limits

Conversation

@asadath1395
Copy link
Contributor

@asadath1395 asadath1395 commented Mar 28, 2024

What does this PR do?

Fixes #8985

https://www.loom.com/share/7db5ef02bc0746419c083d38998a6a48?sid=0e487055-5f25-48ae-a634-30e9da88dd7f

Type of change

  • New feature (non-breaking change which adds functionality)

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

@asadath1395 asadath1395 marked this pull request as draft March 28, 2024 07:04
@vercel
Copy link

vercel bot commented Mar 28, 2024

@asadath1395 is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Mar 28, 2024
@graphite-app graphite-app bot requested a review from a team March 28, 2024 07:04
@github-actions
Copy link
Contributor

github-actions bot commented Mar 28, 2024

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

@github-actions github-actions bot added event-types area: event types, event-types Medium priority Created by Linear-GitHub Sync ✨ feature New feature or request labels Mar 28, 2024
@graphite-app
Copy link

graphite-app bot commented Mar 28, 2024

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (03/28/24)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (03/28/24)

1 label was added to this PR based on Keith Williams's automation.

"Add foundation team as reviewer" took an action on this PR • (04/16/24)

1 reviewer was added to this PR based on Keith Williams's automation.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 28, 2024

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

New Page Added

The following page was added to the bundle from the code in this PR:

Page Size (compressed) First Load % of Budget (350 KB)
/settings/my-account/bookings 311.71 KB 540.14 KB 154.33%

@keithwillcode keithwillcode added this to the v4.0 milestone Mar 28, 2024
@github-actions github-actions bot added the ❗️ migrations contains migration files label Mar 29, 2024
@dosubot dosubot bot modified the milestones: v4.0, v4.1 Apr 15, 2024
@keithwillcode keithwillcode modified the milestones: v4.0, v4.1 Apr 15, 2024
@asadath1395 asadath1395 marked this pull request as ready for review July 2, 2025 05:44
@asadath1395 asadath1395 requested a review from a team July 2, 2025 05:44
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.

cubic found 2 issues across 23 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

allowSEOIndexing: user.allowSEOIndexing,
receiveMonthlyDigestEmail: user.receiveMonthlyDigestEmail,
...profileData,
bookingLimits: intervalLimitsType.parse(user.bookingLimits || {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Defaulting null bookingLimits to an empty object ({}) changes semantics—null represents "no limits", while {} passes validation as an object and may be treated as "limits present but empty", potentially altering downstream logic.

Suggested change
bookingLimits: intervalLimitsType.parse(user.bookingLimits || {}),
bookingLimits: intervalLimitsType.parse(user.bookingLimits ?? null),

allowSEOIndexing: user.allowSEOIndexing,
receiveMonthlyDigestEmail: user.receiveMonthlyDigestEmail,
...profileData,
bookingLimits: intervalLimitsType.parse(user.bookingLimits || {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Using Zod's parse here means any malformed data will synchronously throw a ZodError and crash the entire request path; prefer safeParse (or a try/catch) to return a controlled error response instead of a 500.

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.

cubic found 1 issue across 23 files. Review it in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

allowSEOIndexing: user.allowSEOIndexing,
receiveMonthlyDigestEmail: user.receiveMonthlyDigestEmail,
...profileData,
bookingLimits: intervalLimitsType.parse(user.bookingLimits || {}),
Copy link
Contributor

Choose a reason for hiding this comment

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

Using Zod's parse here means any malformed data will synchronously throw a ZodError and crash the entire request path; prefer safeParse (or a try/catch) to return a controlled error response instead of a 500.

async () => await handleNewBooking({ bookingData: mockBookingData2 })
).rejects.toThrowError("booking_limit_reached");
});
test(`Booking limits per year`, async ({}) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@CarinaWolli We do have tests for booking limits per year

Copy link
Member

Choose a reason for hiding this comment

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

This test is for handleNewBooking, which is working as expected and throws the error when the limit is reached. The actual bug is in availability loading, it shouldn't show open slots if the limit is already reached

@asadath1395 asadath1395 requested a review from CarinaWolli July 2, 2025 06:34
@asadath1395
Copy link
Contributor Author

@CarinaWolli Would you please review this PR? Maintaining this, is becoming cumbersome. Some type checks are failing, don't think they are related to my changes

@CarinaWolli
Copy link
Member

I am still getting the error on the yearly limit. How to reproduce:

  1. One booking per year limit
  2. Create your first booking
  3. Try to book another slot, it still shows availability but it's throwing an error when trying to confirm the booking

@CarinaWolli CarinaWolli modified the milestones: v5.5, v5.6 Jul 16, 2025
@dosubot dosubot bot modified the milestone: v5.6 Jul 16, 2025
@keithwillcode
Copy link
Contributor

@volnei is looking into getting the merge conflicts resolved and the PR tested to merge

@volnei
Copy link
Contributor

volnei commented Aug 14, 2025

Superseded by #23100

@volnei volnei closed this Aug 14, 2025
@dosubot dosubot bot modified the milestone: v5.6 Aug 14, 2025
@asadath1395
Copy link
Contributor Author

@volnei Thanks for taking over! Disappointed that i couldn't take it to the finish line :(. Hope we can get your PR merged soon.

@dosubot dosubot bot modified the milestones: v5.6, v5.7 Aug 18, 2025
@dosubot dosubot bot modified the milestones: v5.7, v5.8 Sep 16, 2025
@dosubot dosubot bot modified the milestones: v5.8, v5.9 Oct 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api area: API, enterprise API, access token, OAuth bookings area: bookings, availability, timezones, double booking community Created by Linear-GitHub Sync event-types area: event types, event-types ✨ feature New feature or request high-risk Requires approval by Foundation team Medium priority Created by Linear-GitHub Sync ❗️ migrations contains migration files ready-for-e2e 💰 Rewarded Rewarded bounties on Algora.io Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-1724] Allow global booking limits

10 participants