fix(customer): list customers for default billing profile when filtered#4369
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR enhances customer listing to intelligently resolve each customer's effective billing profile: if a customer has an override, use that; otherwise, fall back to the namespace default. The implementation introduces two helpers that build dynamic SQL predicates, and comprehensive test coverage validates the behavior across override states. ChangesBilling Profile Filtering for Customer List
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/customer/customer.go (1)
789-815: ⚡ Quick winNice coverage — consider tossing in
Ne/Incases too.The two
eqsubtests nail the main bug, but the dual-branch predicate (override vs. default fallback) also flows throughNe,In, and theAnd/Orwrappers. SQL three-valued logic onbilling_profile_id IS NULLin the override branch is a subtle spot — a quickNe pinnedcase (where customers withIS NULLoverrides should still be included via the default branch) would lock that behavior in place against future regressions.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/customer/customer.go` around lines 789 - 815, Add tests exercising negative and set membership cases for the dual-branch billing_profile_id predicate: add a t.Run("ne pinned") that calls customerService.ListCustomers with BillingProfileID: &filter.FilterULID{FilterString: filter.FilterString{Ne: &pinnedProfile.ID}} and assert that customers with NULL overrides still match via the default branch (expect IDs: noOverride.ID, overrideNullProfile.ID, overrideDefault.ID, overrideSoftDeleted.ID); also add a t.Run("in pinned,default") using FilterULID{FilterString: filter.FilterString{In: &[]ulid.ULID{pinnedProfile.ID, defaultProfile.ID}}} and assert the appropriate set of IDs (including overridePinned when pinned is present and default-fallback matches others); mirror similar cases under And/Or wrappers if present to lock behavior around SQL three-valued NULL handling for BillingProfileID in customer.ListCustomers and associated predicate logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@test/customer/customer.go`:
- Around line 789-815: Add tests exercising negative and set membership cases
for the dual-branch billing_profile_id predicate: add a t.Run("ne pinned") that
calls customerService.ListCustomers with BillingProfileID:
&filter.FilterULID{FilterString: filter.FilterString{Ne: &pinnedProfile.ID}} and
assert that customers with NULL overrides still match via the default branch
(expect IDs: noOverride.ID, overrideNullProfile.ID, overrideDefault.ID,
overrideSoftDeleted.ID); also add a t.Run("in pinned,default") using
FilterULID{FilterString: filter.FilterString{In: &[]ulid.ULID{pinnedProfile.ID,
defaultProfile.ID}}} and assert the appropriate set of IDs (including
overridePinned when pinned is present and default-fallback matches others);
mirror similar cases under And/Or wrappers if present to lock behavior around
SQL three-valued NULL handling for BillingProfileID in customer.ListCustomers
and associated predicate logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 6ec51bfb-e79e-4ab6-a809-4666465bd5a7
📒 Files selected for processing (3)
openmeter/customer/adapter/customer.gotest/customer/customer.gotest/customer/customer_test.go
Summary by CodeRabbit
Bug Fixes
Tests