feat(api): add v3 customer and subscription list filters#4336
Conversation
📝 WalkthroughWalkthroughThis PR expands customer and subscription list operations with new filter capabilities while modernizing filtering logic. It introduces ChangesCustomer and Subscription Filter Expansion
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
openmeter/customer/adapter/customer.go (1)
79-89: 💤 Low valueConsider whether billing overrides should support delayed deletion like subject keys do.
The
BillingProfileIDfilter usesDeletedAtIsNil()for soft-delete filtering, whileUsageAttributionSubjectKeyusesDeletedAtIsNil() || DeletedAtGTE(now). The subjects pattern allows records marked for future deletion to remain visible until that date passes. If billing overrides should support the same delayed-deletion feature, align the filters for consistency.🤖 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 `@openmeter/customer/adapter/customer.go` around lines 79 - 89, The BillingProfileID filter currently only uses billingcustomeroverridedb.DeletedAtIsNil() which excludes records scheduled for future deletion; to match the UsageAttributionSubjectKey behavior, update the predicate in the customer query (the block using filter.SelectPredicate[predicate.BillingCustomerOverride] and billingcustomeroverridedb.FieldBillingProfileID) to allow records with DeletedAt == nil OR DeletedAt >= now—i.e., replace the single DeletedAtIsNil() condition with a combined condition like billingcustomeroverridedb.DeletedAtIsNil() || billingcustomeroverridedb.DeletedAtGTE(time.Now()) so billing overrides support delayed deletion the same way subject keys do.
🤖 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.
Inline comments:
In `@openmeter/billing/worker/subscriptionsync/reconciler/reconciler.go`:
- Around line 106-107: The CustomerID filter is always constructed even when
in.Customers is empty; change the code that builds the filter object so that the
CustomerID field is only set when len(in.Customers) > 0 (i.e., create
&filter.FilterULID{FilterString{In: &in.Customers}} only inside that
conditional), otherwise leave CustomerID nil; update the block where Namespaces
and CustomerID are assigned (the code that currently uses CustomerID:
&filter.FilterULID{FilterString: filter.FilterString{In: &in.Customers}}) to
perform this conditional assignment so downstream ApplyToQuery sees nil instead
of a pointer to an empty slice.
---
Nitpick comments:
In `@openmeter/customer/adapter/customer.go`:
- Around line 79-89: The BillingProfileID filter currently only uses
billingcustomeroverridedb.DeletedAtIsNil() which excludes records scheduled for
future deletion; to match the UsageAttributionSubjectKey behavior, update the
predicate in the customer query (the block using
filter.SelectPredicate[predicate.BillingCustomerOverride] and
billingcustomeroverridedb.FieldBillingProfileID) to allow records with DeletedAt
== nil OR DeletedAt >= now—i.e., replace the single DeletedAtIsNil() condition
with a combined condition like billingcustomeroverridedb.DeletedAtIsNil() ||
billingcustomeroverridedb.DeletedAtGTE(time.Now()) so billing overrides support
delayed deletion the same way subject keys do.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 3fe3bd45-cba4-49f9-b67f-11a6df3e42b2
⛔ Files ignored due to path filters (1)
api/v3/openapi.yamlis excluded by!**/openapi.yaml
📒 Files selected for processing (16)
api/spec/packages/aip/src/customers/operations.tspapi/spec/packages/aip/src/subscriptions/operations.tspapi/v3/api.gen.goapi/v3/handlers/customers/list.goapi/v3/handlers/subscriptions/list.goopenmeter/billing/validators/customer/customer.goopenmeter/billing/worker/subscriptionsync/reconciler/reconciler.goopenmeter/customer/adapter/customer.goopenmeter/customer/customer.goopenmeter/customer/httpdriver/customer.goopenmeter/productcatalog/subscription/http/get.goopenmeter/subscription/list.goopenmeter/subscription/repo/subscriptionrepo.goopenmeter/subscription/validators/customer/validator.goopenmeter/subscription/validators/subscription/validator.goopenmeter/subscription/workflow/service/subscription.go
Summary by CodeRabbit
Release Notes
usage_attribution_subject_key,plan_key, andbilling_profile_idparametersplan_keyfilter support to subscription list endpoint