Fix circular dependency when creating DirectionRate with auto_rate#95
Open
Fix circular dependency when creating DirectionRate with auto_rate#95
Conversation
When auto_rate is enabled, DirectionsRatesJob calls exchange_rate.final_rate_percents which eventually needs exchange_rate.currency_rate. Previously currency_rate was delegated to direction_rate, but direction_rate doesn't exist yet during snapshot creation - causing FinitRateNotFound error. Now currency_rate is fetched directly from CurrencyRatesRepository by currency_pair, breaking the circular dependency chain. Co-Authored-By: Claude Opus 4.5 <[email protected]>
dapi
requested changes
Jan 29, 2026
| # Get currency_rate directly from repository to avoid circular dependency | ||
| # when creating DirectionRate (direction_rate -> exchange_rate.currency_rate -> direction_rate) | ||
| def currency_rate | ||
| @currency_rate ||= Universe.currency_rates_repository.find_currency_rate_by_pair(currency_pair) |
There was a problem hiding this comment.
так может выдутая совершенной другой currency_rate. было все верно. В чем именно проблема-то?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When auto_rate is enabled, DirectionsRatesJob calls exchange_rate.final_rate_percents which eventually needs exchange_rate.currency_rate. Previously currency_rate was delegated to direction_rate, but direction_rate doesn't exist yet during snapshot creation - causing FinitRateNotFound error.
Now currency_rate is fetched directly from CurrencyRatesRepository by currency_pair, breaking the circular dependency chain.