Repository navigation
feat(customer): get by usage attribution - #3082
Conversation
📝 WalkthroughWalkthroughA new method, Changes
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
openmeter/customer/service/customer.go (1)
84-87: Implementation is correct, but consider input validation for consistency.The method correctly delegates to the adapter following the established pattern. However, unlike other service methods (
CreateCustomer,UpdateCustomer,DeleteCustomer), this method doesn't perform input validation through the request validator registry.Consider adding validation for consistency:
func (s *Service) GetCustomerByUsageAttribution(ctx context.Context, input customer.GetCustomerByUsageAttributionInput) (*customer.Customer, error) { + // Validate the input + if err := s.requestValidatorRegistry.ValidateGetCustomerByUsageAttribution(ctx, input); err != nil { + return nil, models.NewGenericValidationError(err) + } + return s.adapter.GetCustomerByUsageAttribution(ctx, input) }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
openmeter/customer/adapter.go(1 hunks)openmeter/customer/adapter/customer.go(4 hunks)openmeter/customer/customer.go(1 hunks)openmeter/customer/service.go(1 hunks)openmeter/customer/service/customer.go(1 hunks)openmeter/server/server_test.go(1 hunks)test/customer/customer.go(1 hunks)test/customer/customer_test.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
openmeter/customer/service.go (3)
openmeter/customer/customer.go (2)
GetCustomerByUsageAttributionInput(141-144)Customer(15-24)openmeter/ent/schema/customer.go (5)
Customer(17-19)Customer(21-28)Customer(30-38)Customer(40-53)Customer(55-67)openmeter/ent/db/customer.go (2)
Customer(20-62)Customer(129-144)
openmeter/customer/customer.go (3)
openmeter/ent/db/customersubjects/where.go (2)
Namespace(59-61)SubjectKey(69-71)pkg/models/validator.go (1)
Validate(16-26)pkg/models/errors.go (1)
NewGenericValidationError(138-140)
openmeter/customer/adapter.go (4)
openmeter/customer/customer.go (2)
GetCustomerByUsageAttributionInput(141-144)Customer(15-24)api/api.gen.go (1)
Customer(2113-2160)api/client/go/client.gen.go (1)
Customer(1943-1990)openmeter/ent/db/predicate/predicate.go (1)
Customer(153-153)
test/customer/customer.go (1)
openmeter/customer/customer.go (5)
Customer(15-24)CreateCustomerInput(187-190)CustomerMutate(47-56)CustomerUsageAttribution(127-129)GetCustomerByUsageAttributionInput(141-144)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (go)
- GitHub Check: Artifacts / Container image
- GitHub Check: Artifacts / Benthos Collector Container image
- GitHub Check: E2E
- GitHub Check: CI
- GitHub Check: Quickstart
- GitHub Check: Test
- GitHub Check: Migration Checks
- GitHub Check: Lint
- GitHub Check: Developer environment
- GitHub Check: Build
- GitHub Check: Commit hooks
🔇 Additional comments (9)
test/customer/customer_test.go (1)
42-44: LGTM! Test integration follows established patterns.The new test case is properly integrated into the existing test suite and follows the same pattern as other tests.
openmeter/customer/adapter.go (1)
21-21: LGTM! Interface method addition is consistent.The new method follows the established pattern of other interface methods and has appropriate input/output types.
openmeter/customer/service.go (1)
24-24: LGTM! Service interface method is properly defined.The method signature is consistent with the adapter interface and is logically placed within the service interface.
openmeter/server/server_test.go (1)
1037-1039: LGTM! No-op implementation is consistent with testing patterns.The implementation follows the same pattern as other no-op methods and returns appropriate values for testing purposes.
openmeter/customer/customer.go (1)
140-156: LGTM! Well-structured input struct and validation.The new
GetCustomerByUsageAttributionInputstruct follows the established patterns in the codebase with proper validation logic. The validation method correctly checks for required fields and uses consistent error handling.test/customer/customer.go (1)
538-570: LGTM! Comprehensive test coverage for the new functionality.The test method follows the established patterns in the test suite and provides good coverage of the
GetCustomerByUsageAttributionfunctionality. It properly:
- Sets up the test environment with a namespace
- Creates a customer with usage attribution subject keys
- Exercises the new method with valid input
- Validates all expected fields in the response
openmeter/customer/adapter/customer.go (3)
40-42: LGTM! Good refactoring to use helper functions.The refactoring improves code modularity by extracting common query building logic into reusable helper functions.
307-309: LGTM! Consistent use of helper functions.The refactoring maintains consistency with the
ListCustomersmethod and improves code maintainability.
615-635: LGTM! Well-designed helper functions.The helper functions properly encapsulate common query building logic:
withSubjectscorrectly filters out deleted subjectswithActiveSubscriptionandwithSubscriptionproperly handle subscription filtering and plan loadingThese functions improve code maintainability and reduce duplication.
Lookup customer by usage attribution subject key.
Summary by CodeRabbit