Skip to content

fix(registration-stats): count badge features inherited from the badge type - #657

Open
romanetar wants to merge 1 commit into
mainfrom
fix/registration-stats-badge-feature-inherited
Open

romanetar wants to merge 1 commit into
mainfrom
fix/registration-stats-badge-feature-inherited

Conversation

@romanetar

@romanetar romanetar commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

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

Problem

getActiveTicketsPerBadgeFeatureType and getAttendeesCheckinPerBadgeFeatureType feed sold_qty and checkin_qty of the "tickets per badge feature type" block of GET /summits/all/{id}/registration-stats.

Their join to SummitBadgeFeatureType compared the same column on both sides of an OR, and the LEFT JOIN to SummitBadgeType_BadgeFeatures was never referenced. Features a badge inherits from its badge type were therefore never counted, unlike SummitAttendeeBadge::getAllFeatures() and the badge serializer, which merge both levels. Both methods also wrapped everything in a try/catch that returned [], so a SQL error rendered as "0 sold".

Changes

  • Both queries share a private helper that builds a UNION ALL of the badge-level branch (SummitAttendeeBadge_Features) and the badge-type-level branch (SummitBadgeType_BadgeFeatures via BadgeTypeID), then counts DISTINCT tickets per feature name. A feature granted at both levels counts once.
  • The check-in variant keeps the SummitAttendee.SummitHallCheckedIn = 1 join.
  • addDatesFilteringWithTimeZone is applied to each branch, since it concatenates onto the WHERE clause and would otherwise only filter the last one.
  • Removed the dead join and the try/catch that swallowed exceptions.
  • Added RegistrationStatsBadgeFeatureTest (runs in the Repositories CI job): badge-level, type-level and both-levels features for sold_qty and checkin_qty, plus a date filter test covering both branches. The three tests fail against the previous queries.

Notes

  • Displayed numbers change upward only, on summits that have badge-type-level features (8, 18 and 23 on prod-12). Summit 73 is unchanged.
  • The queries still filter on SummitOrder.SummitID: SummitAttendeeTicket.SummitID is not mapped on main, it comes with the registration-stats performance work. Once that lands, the predicate can move in both branches.
  • The performance criteria (no sort merge pass, at most 100 ms) can only be measured on prod-12.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Badge-feature statistics now include features assigned through badge types as well as features assigned directly to badges.
    • Ticket sales and check-in counts apply date filters consistently, so results reflect the selected date range.
    • Check-in counts include only attendees who have checked in.

…e type

The tickets per badge feature type queries joined SummitBadgeFeatureType
with the same column on both sides of an OR and never referenced the
SummitBadgeType_BadgeFeatures join, so features a badge inherits from its
badge type were not counted in sold_qty and checkin_qty.

Rewrite both queries as a UNION ALL of the badge level and the badge type
level branches, counting distinct tickets per feature name, which matches
SummitAttendeeBadge::getAllFeatures. The date filter is applied to each
branch. Drop the try/catch that swallowed SQL errors and returned an empty
result, so a failure no longer renders as zero sold.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 97da3dac-601b-4550-bf2f-806e2c51e834
Commits

Reviewing files that changed from the base of the PR and between 0eac852 and 05f443e.

Files selected for processing: 2
  • app/Models/Foundation/Summit/SummitRegistrationStats.php
  • tests/Repositories/RegistrationStatsBadgeFeatureTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The registration statistics query now counts features assigned directly to badges and features inherited from badge types. Active-ticket and checked-in counts apply optional date filters to both feature branches. Tests cover feature counts and date filtering.

Changes: Badge-feature registration statistics

Layer / File(s) Summary
Shared query and coverage
app/Models/Foundation/Summit/SummitRegistrationStats.php, tests/Repositories/RegistrationStatsBadgeFeatureTest.php
A shared query counts distinct active, paid tickets by feature type across badge-level and badge-type features. Both public methods delegate to it. The checked-in query joins attendees and filters for checked-in status. Date filtering applies to both query branches. Tests cover direct and inherited features, checked-in counts, and date filtering. Query exceptions now propagate instead of returning an empty array.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: smarcet

Merge Risk: Minimal · up to 05f44

The change makes registration statistics count badge features inherited from the badge type, and it stops SQL errors from being reported as empty results. No merge-blocking risk was found, and the added tests cover the new counting and date-filter behavior.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: counting registration statistics for badge features inherited from badge types.
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.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions

Copy link
Copy Markdown

📘 OpenAPI / Swagger preview

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

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

@romanetar
romanetar requested a review from smarcet October 26, 2026 14:13

This branch has not been deployed

No deployments
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.

1 participant