feat: add expand option to currency list api - #4771
Conversation
📝 WalkthroughWalkthroughCurrency listing and retrieval now support time-filtered cost-basis expansion. Batch resolution requests the expansion, custom currency queries apply shared effective-time filtering, and service tests cover active, fiat, and deleted currency results. ChangesCurrency cost-basis expansion
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant BatchResolveCurrencies
participant CurrencyService
participant CustomCurrencyAdapter
participant CostBasisHistory
BatchResolveCurrencies->>CurrencyService: request CostBasis expansion
CurrencyService->>CustomCurrencyAdapter: list currencies
CustomCurrencyAdapter->>CostBasisHistory: apply WithCostBasis
CostBasisHistory-->>CustomCurrencyAdapter: return effective records
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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
🤖 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/currencies/service/service_test.go`:
- Around line 193-257: Add future-dated and expired cost-basis fixtures in the
ListWithCostBasis test before calling ListCurrencies. Configure them for the
custom currency, then assert the expanded CostBasis contains only the currently
effective entry, preserving the existing fiat assertions and expected counts.
🪄 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: ce9ebfec-7ac9-4435-9c4f-5a81cc502e33
📒 Files selected for processing (4)
openmeter/currencies/adapter/currencies.goopenmeter/currencies/currencyresolver/resolver.goopenmeter/currencies/service.goopenmeter/currencies/service/service_test.go
gergely-kurucz-konghq
left a comment
There was a problem hiding this comment.
LGTM! Small nit comment, consider if it makes sense.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/currencies/adapter/currencies.go`:
- Around line 171-176: Capture the return value of WithCostBasis at both call
sites in the currency query flow, including the branches using now and at, by
reassigning the returned query back to q before continuing. Do not rely on
in-place mutation of the Ent builder; preserve the existing conditional
eager-loading behavior.
- Around line 370-397: Update the non-null customcurrency.deleted_at branch in
WithCostBasis to also enforce the cost-basis effective window: effective_from
must be at or before at, and effective_to must be null or after at. Preserve its
existing deletion-timestamp equality condition and keep the active-currency
branch unchanged.
🪄 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: 9b73203e-4d69-4f2e-96dc-96d67bc1c308
📒 Files selected for processing (1)
openmeter/currencies/adapter/currencies.go
fc01e09 to
9156b94
Compare
Overview
Add expand options to list currencies service API.
Fixes #(issue)
Notes for reviewer
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Greptile Summary
This PR adds cost-basis expansion to currency listing and resolution. The main changes are:
Confidence Score: 4/5
The deleted-currency query should be corrected before merging.
openmeter/currencies/adapter/currencies.go
Important Files Changed
Prompt To Fix All With AI
Reviews (3): Last reviewed commit: "refactor: sideloading costbasis for curr..." | Re-trigger Greptile
Context used (3)