Skip to content

feature/waitlist - #209

Open
JotinderBhamra wants to merge 2 commits into
mainfrom
waitlist
Open

JotinderBhamra wants to merge 2 commits into
mainfrom
waitlist

Conversation

@JotinderBhamra

Copy link
Copy Markdown
Contributor

What does this PR do?

Type of change

  • Feature
  • Bug fix
  • Chore / config
  • Hotfix

Checklist

  • My branch follows the naming convention (feature/, fix/, chore/, hotfix/)
  • My commit messages follow the conventional commits format
  • CI checks pass

Linked Issues

Closes #205
Addresses #
Related to #

@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ssa Ready Ready Preview Oct 24, 2026 12:35am UTC

@joengy joengy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Only 2 comments to address Jotinder, just let me know if you have any issues with them otherwise really great job overall. 4000 mi bombaclat lines of code added

hooks: {
afterRead: [
async ({ doc, req }) => {
Object.assign(doc, await getEventAvailability(req.payload, doc.id, doc.capacity, req))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This adds one extra database query for every event that's read, anywhere.

afterRead runs once per document. So any time events are fetched, each event also runs a count on event-registrations. The past events page asks for every past event (limit=0), so with 50 past events that's 50 extra queries on every page load. The admin list view gets slower the same way. Past events don't need availability at all.

Suggested fix: only work out availability where it's actually needed, which is the upcoming event (for the RSVP page) and the signup hook (which already calls getEventAvailability itself). For example:

  • skip it when the event has no capacity (no capacity means no waitlist, so there's nothing to count), and/or
  • skip it when doc.isUpcoming !== true.

Either check is one line at the top of the hook and removes almost all of the extra queries.

price_data: {
currency: 'nzd',
unit_amount: amountInCents,
unit_amount: Math.round(registration.amount * 100),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

An abandoned checkout holds a place for 24 hours.

A pending registration counts towards capacity (mainListStatuses includes 'pending'). It only gets released when the checkout.session.expired webhook arrives, and by default Stripe Checkout sessions expire after 24 hours. So if someone clicks through to payment and then closes the tab, that place is gone for a day. When an event is close to full, a few abandoned checkouts could push new people onto the waitlist even though there's actually room.

Suggested fix: set a shorter expiry on the session, e.g.

expires_at: Math.floor(Date.now() / 1000) + 30 * 60, // 30 min, Stripe's minimum

Then unpaid places are released after half an hour, and the existing expiry webhook does the rest.

This branch was successfully deployed

1 active deployment
Preview — cbd7bb2e Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Waitlists

2 participants