Repository navigation
feature/waitlist - #209
feature/waitlist#209JotinderBhamra wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
joengy
left a comment
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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 minimumThen unpaid places are released after half an hour, and the existing expiry webhook does the rest.
What does this PR do?
Type of change
Checklist
feature/,fix/,chore/,hotfix/)Linked Issues
Closes #205
Addresses #
Related to #