fix(promo-codes): persist quantity_available for generic SUMMIT_PROMO_CODE class - #586
Conversation
…_CODE class SummitPromoCodeFactory::populate() applied quantity_available for every promo code class except the generic SummitRegistrationPromoCode, so the field was silently dropped on create and update. Codes meant to be limited (one-off, N uses) ended up stored with 0, which the platform treats as unlimited use. Adds the missing case to the per-class switch and a regression test.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe promo code factory now stores ChangesPromo code quantity persistence
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change makes generic summit promo-code quantity limits persist as intended and includes focused regression coverage; no actionable merge-blocking risk remains after normal checks and review. Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
📘 OpenAPI / Swagger preview ➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-586/ This page is automatically updated on each push to this PR. |
…_CODE class (#586) SummitPromoCodeFactory::populate() applied quantity_available for every promo code class except the generic SummitRegistrationPromoCode, so the field was silently dropped on create and update. Codes meant to be limited (one-off, N uses) ended up stored with 0, which the platform treats as unlimited use. Adds the missing case to the per-class switch and a regression test.
ref: https://app.clickup.com/t/9014802374/86bbebyex
Problem
SummitPromoCodeFactory::populate()appliesquantity_availablefor every promo code class (member, speaker, sponsor, discount, domain-authorized) except the genericSummitRegistrationPromoCode(SUMMIT_PROMO_CODE) — the per-classswitchhas no case for it, so the field is silently dropped on both create and update (both paths go throughpopulate()).Request validation accepts the field (
PromoCodesValidationRulesFactory,sometimes|integer|min:0) and show-admin sends it, so admins believe the limit was saved. Sincequantity_available = 0means unlimited use, codes intended to be one-off / N-uses end up with no usage cap at all.Found while investigating ClickUp 86bbebyex: two prod promo codes for summit 73 (
HP31BS1, intended 1 use;26GLOSTAFF, intended 24 uses) were stored withQuantityAvailable = 0— i.e. effectively unlimited. Data was corrected manually; this PR fixes the root cause.Fix
Add the missing
SummitRegistrationPromoCode::ClassNamecase to thepopulate()switch, applyingquantity_availablethe same way every other class already does.setQuantityAvailable()already validates the value.Deliberately not included:
PrePaidSummitRegistrationPromoCode(the other class without a case) — itsquantity_availableis managed by the prepaid purchase flow, and making it admin-editable is a separate product decision.Test
tests/Unit/Services/SummitPromoCodeFactoryTest::testPopulatePersistsQuantityAvailableForGenericSummitPromoCode— red/green verified: fails with0 !== 24without the fix, passes with it. Full test class 3/3 green inside the Docker stack.Summary by CodeRabbit
Bug Fixes
Tests