Repository navigation
feat(creditgrant): add sorting to grant listing - #5376
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Sort query contract and transport api/spec/packages/aip/..., api/spec/packages/aip-client-javascript/src/..., api/v3/api.gen.go, api/v3/client/customers_credits_grants.go |
The API specification and generated models add the optional sort parameter. The JavaScript and Go clients encode it in list requests. |
Parse, validate, and forward sort values api/v3/handlers/customers/credits/list_grants.go, api/v3/handlers/customers/credits/list_grants_test.go, openmeter/billing/creditgrant/service.go, openmeter/billing/creditgrant/service/service.go |
The handler defaults to created_at descending, parses supplied values, and rejects invalid or unsupported sorts. The credit-grant service validates and forwards the sort key and direction. Endpoint tests cover default, valid, and invalid sort values. |
Order results and verify pagination openmeter/billing/charges/creditpurchase/adapter.go, openmeter/billing/charges/creditpurchase/adapter/charge.go, test/credits/creditgrant_test.go, openmeter/billing/charges/README.md |
The charge-listing adapter validates sort keys and directions, then orders results before pagination. Integration tests cover default and explicit sorting across pages. The README documents the default order and ID tie-break behavior. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant APIClient
participant ListCreditGrantsHandler
participant CreditGrantService
participant CreditPurchaseService
APIClient->>ListCreditGrantsHandler: Sends sort query
ListCreditGrantsHandler->>CreditGrantService: Passes OrderBy and Order
CreditGrantService->>CreditPurchaseService: Forwards OrderBy and Order
CreditPurchaseService->>CreditPurchaseService: Orders results before pagination
Suggested reviewers: turip, tothandras, borosr
Merge Risk: 
Minimal · up to ed071
-
Credit-grant sorting appears ready to merge after normal checks; no material issue was identified.
Pre-merge checks: 
4
Finishing Touches
-
📝 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.
Comment @coderabbitai help to get the list of available commands.
Overview
Credit grant listing currently has no explicit ordering. Add the existing AIP-style
sortquery parameter and default tocreated_at desc.Supports
created_at,updated_at,name, andid, with an optionalascordescsuffix. Sorting happens before pagination, withidbreaking ties in the same direction. Invalid sort expressions return HTTP 400. Regenerated the v3 OpenAPI, server bindings, and Go/TypeScript SDKs.Notes for reviewer
Validation passed: HTTP handler and credit-grant service tests; PostgreSQL credit-grant and credit-purchase tests; Go SDK build/vet/tests; TypeScript typecheck and all 552 SDK tests; focused Go lint/style checks;
git diff --check.Full
make gen-apiis blocked by the legacy Python emitter's missing virtualenv. Affected v3 generation completed successfully.Summary by CodeRabbit


Confidence Score: 5/5
The PR appears safe to merge.Summary
Adds sorting to credit grant lists across the API, service, database query, and Go/TypeScript SDKs.
No actionable issues found. Tests were inspected, not run during this review.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[Client sort query] --> B{Parse and check field} B -->|Invalid| C[HTTP 400] B -->|Valid or omitted| D[Grant service] D --> E[Apply filters] E --> F[Sort with ID tie-break] F --> G[Apply pagination] G --> H[Return grants]Reviews (1) · Last reviewed commit: "feat(creditgrant): add sorting to grant ..." · Reviewed by Greptile