fix(events): stop subtracting sold from amount_tickets #174
No reviewers
Labels
No labels
app:activities
app:chat
app:chatelet
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp!174
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/my-events-availability-arithmetic"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #173
amount_ticketsis the remaining count — the backend decrements it on every sale and incrementssold, so the two describe the same tickets.MyEventsPage.vuesubtracted one from the other, removing each sale twice.This is disabling the buy button in production
Because
remaining + soldis the original capacity,amount_tickets <= soldfirst becomes true at exactly the halfway point. The purchase button dies once an event sells half its seats.The backend half shipped as
aiolabs/events#59inv1.6.1-aio.17, which makes the mismatch worse: the server now sells correctly while the webapp refuses. On aio-demo:The API disagrees with all three —
POST /events/api/v1/tickets/KVhCGUrGFP6UyBuEaRA5Zdwith quantity 10 returns "Only 9 ticket(s) remaining", not sold out.Swept the rest of the module: these were the only two occurrences.
EventDetailPage.vueandEventCard.vuereadticketInfo.availablestraight from thetickets_availableNIP-52 tag and are correct — this page reads the RESTEventshape instead, which is how it diverged.Capacity is now required, minimum 1
A capacity of
0meant "unlimited" in this form. Nothing on the backend agreed —api_get_eventandapi_ticket_createboth readamount_tickets < 1as sold out, so a0produced an event that advertised "Unlimited tickets" on the card and returned 410 to every purchase. Three such events exist on demo right now.aiolabs/events#62stops publishing the lie; this stops the form creating it.Four coordinated edits:
.min(1)with a real message,.default(0)dropped so the field is genuinely requiredundefined— the organiser chooses rather than inheriting a broken default|| undefined, so opening an existing zero-capacity event presents an empty fieldFormDescriptionno longer says0 = unlimited; inputmin="1"The one-line change that unblocks the backend
The falsy check dropped
0from the request entirely.aiolabs/eventswantsamount_ticketsrequired (ge=1) — the last piece of events#34 — and that would have 422'd this dialog for exactly the case users were picking. Ordering is: this ships, then the backend tightens.Testing
vue-tsc --noEmitexit 0 ·vitest run51 passed ·npm run buildexit 0.Not included
types/event.ts:100derivestotal = available + sold, which is the10 of 17inflation from the original events#34 report — correct only while capacity is never edited, since an edit re-baselines remaining. That's the display half of events#34, parked for the v1.6.8 rebase, and it reads the NIP-52 tag rather than the REST shape. Different code path; not widening this PR to reach it.Release path
Per the webapp flow this targets
dev. Wants awebapp-devflake.lock bump and a smoke on aio-demo beforemain— the three stuck events there are a ready-made check: their buy buttons should come alive.