fix(tickets): amount_tickets is the remaining count, stop subtracting sold #59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/amount-tickets-remaining"
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?
Refs #34 — the live half of it. Deliberately not
Closes; see scope below.set_ticket_paiddecrementsamount_ticketson every sale and incrementssold, so the two describe the same tickets.api_ticket_createthen did:which removes each sale twice.
This is refusing sales right now
Because
remaining + soldis the original capacity,sold >= amount_ticketsfirst becomes true at exactly the halfway point — so every event locks itself as sold out once half its seats have gone. Measured on aio-demo before the fix:Three events turning away buyers with stock on the shelf, thirteen more under-reporting availability. Demo is test data, but the same code runs on cfaun, four84 and atio.
The fix removes divergence rather than adding any
The arithmetic was ours, introduced with the multi-quantity purchase feature. Upstream has no equivalent — it sells one ticket per request and reads
amount_ticketsas remaining everywhere (services.py:95-105,views_api.py:188and:415). So this restores upstream's own guard plus the single linequantityactually needs:Net effect on #33: slightly easier, not harder. Checked the rest of the codebase — this arithmetic existed in exactly one place, including the Quasar frontend.
Scope
Only the double-subtraction. The rest of #34 waits for #33, as agreed on the issue:
0 = unlimitedreading10 of 17inflationThose need ticket waves in view, since v1.6.8 makes
amount_ticketsa per-wave roll-up. This part doesn't.Testing
84 passed(74 + 10 new). The tests walk a 50-seat event to capacity one sale at a time, and pin the boundary empirically rather than by assertion:sold=49passes even without the fix,sold=50is where it used to lock. Six of the ten fail on the unfixed code. ruff and black clean.A detail worth knowing that the tests surfaced:
CreateTicket.quantityis capped atle=10by the model, so the under-reported buyer cap only ever bit events with fewer than ~10 apparent tickets left. The false sold-out is the serious half.Deploy note
Existing rows need no migration —
amount_ticketsalready holds the correct remaining count. Affected events simply start selling again once this ships. Worth re-running the exposure query on each host afterwards to confirm nothing is still stuck.No
config.jsonbump — version gets cut on main per the release procedure.