refactor: cart controller logic update - #20
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe cart controller's currency conversion logic is refactored to use product-specific currencies instead of assuming USD prices, fetch rates on Redis cache miss, and remove the USD default for base currency. Corresponding tests are updated with new fixtures and assertions. Changes
Sequence DiagramsequenceDiagram
participant Client
participant CartController
participant RedisCache
participant RateFetcher
participant CurrencyConverter
Client->>CartController: GET /cart
CartController->>CartController: Get user.baseCurrency
CartController->>RedisCache: Check for rates
alt Cache Hit
RedisCache-->>CartController: Return cached rates
else Cache Miss
CartController->>RateFetcher: fetchGrossRates()
RateFetcher-->>CartController: Return fresh rates
CartController->>RedisCache: Store rates
end
CartController->>CartController: For each cart item
CartController->>CurrencyConverter: Check product.currency vs baseCurrency
alt Currencies Match
CurrencyConverter-->>CartController: Use original price
else Currencies Differ
CurrencyConverter->>CartController: Apply merchant → user currency rate
end
CartController-->>Client: Return cart with converted prices
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
✨ 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 |
Summary by CodeRabbit