Skip to content

Fix bundle purchases summary showing identical totals for every row#288

Merged
simonhamp merged 1 commit into
mainfrom
fix-bundle-purchases-summary
Mar 20, 2026
Merged

Fix bundle purchases summary showing identical totals for every row#288
simonhamp merged 1 commit into
mainfrom
fix-bundle-purchases-summary

Conversation

@simonhamp

@simonhamp simonhamp commented Mar 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Fixed correlated subqueries in the Bundle Purchases relation manager that were returning the same totals for every row
  • The inner subqueries referenced the unaliased plugin_licenses table, causing whereColumn to correlate against itself (always true) instead of the outer query
  • Aliased inner tables as sale_pl and count_pl so sale_total and sale_plugins_count are computed correctly per user/purchase
  • Added tests verifying computed column values per sale and per buyer

Test plan

  • Existing grouping and row count tests still pass
  • New test_it_computes_correct_totals_per_sale verifies a single buyer's totals
  • New test_it_computes_correct_totals_for_each_buyer verifies different buyers get independent totals
  • Manually verify in admin panel that bundle purchases show correct per-customer amounts

🤖 Generated with Claude Code

The correlated subqueries for sale_total and sale_plugins_count referenced
the unaliased plugin_licenses table, making whereColumn correlate against
itself (always true). Aliased inner tables as sale_pl/count_pl so values
are computed per user/purchase. Added tests for computed column correctness.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@simonhamp simonhamp marked this pull request as ready for review March 20, 2026 20:55
@simonhamp simonhamp merged commit efc61e4 into main Mar 20, 2026
2 checks passed
@simonhamp simonhamp deleted the fix-bundle-purchases-summary branch March 20, 2026 21:38
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