Skip to content

fix(promo-codes): persist quantity_available for generic SUMMIT_PROMO_CODE class - #586

Merged
smarcet merged 1 commit into
mainfrom
hotfix/summit-promo-code-quantity-available
Aug 14, 2026
Merged

fix(promo-codes): persist quantity_available for generic SUMMIT_PROMO_CODE class#586
smarcet merged 1 commit into
mainfrom
hotfix/summit-promo-code-quantity-available

Conversation

@smarcet

@smarcet smarcet commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

ref: https://app.clickup.com/t/9014802374/86bbebyex

Problem

SummitPromoCodeFactory::populate() applies quantity_available for every promo code class (member, speaker, sponsor, discount, domain-authorized) except the generic SummitRegistrationPromoCode (SUMMIT_PROMO_CODE) — the per-class switch has no case for it, so the field is silently dropped on both create and update (both paths go through populate()).

Request validation accepts the field (PromoCodesValidationRulesFactory, sometimes|integer|min:0) and show-admin sends it, so admins believe the limit was saved. Since quantity_available = 0 means 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 with QuantityAvailable = 0 — i.e. effectively unlimited. Data was corrected manually; this PR fixes the root cause.

Fix

Add the missing SummitRegistrationPromoCode::ClassName case to the populate() switch, applying quantity_available the same way every other class already does. setQuantityAvailable() already validates the value.

Deliberately not included: PrePaidSummitRegistrationPromoCode (the other class without a case) — its quantity_available is 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 with 0 !== 24 without the fix, passes with it. Full test class 3/3 green inside the Docker stack.

Summary by CodeRabbit

  • Bug Fixes

    • Summit registration promo codes now correctly save the available quantity when provided.
    • Quantity values are consistently stored as whole numbers.
  • Tests

    • Added coverage to verify available quantities persist correctly for summit promo codes.

…_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.
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 883a53be-5df3-4831-a469-2403829dbc1d

📥 Commits

Reviewing files that changed from the base of the PR and between c8c40e1 and 5ed1d7a.

📒 Files selected for processing (2)
  • app/Models/Foundation/Summit/Factories/SummitPromoCodeFactory.php
  • tests/Unit/Services/SummitPromoCodeFactoryTest.php

📝 Walkthrough

Walkthrough

The promo code factory now stores quantity_available for generic SummitRegistrationPromoCode payloads. A unit test verifies that the value is converted and retained.

Changes

Promo code quantity persistence

Layer / File(s) Summary
Quantity availability mapping and regression coverage
app/Models/Foundation/Summit/Factories/SummitPromoCodeFactory.php, tests/Unit/Services/SummitPromoCodeFactoryTest.php
The factory stores quantity_available as an integer when provided. The unit test verifies that a value of 24 is retained.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 5ed1d

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)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: persisting quantity_available for generic SUMMIT_PROMO_CODE promo codes.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotfix/summit-promo-code-quantity-available

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@smarcet
smarcet requested a lite review from Copilot August 14, 2026 18:56
@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-586/

This page is automatically updated on each push to this PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@smarcet
smarcet merged commit 76b79ae into main Aug 14, 2026
22 checks passed
smarcet added a commit that referenced this pull request Aug 14, 2026
…_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.
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.

2 participants