Skip to content

Fix circular dependency when creating DirectionRate with auto_rate#95

Open
m1ndg8mer wants to merge 1 commit intomasterfrom
fix/circular-dependency-currency-rate
Open

Fix circular dependency when creating DirectionRate with auto_rate#95
m1ndg8mer wants to merge 1 commit intomasterfrom
fix/circular-dependency-currency-rate

Conversation

@m1ndg8mer
Copy link
Copy Markdown

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.

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]>
# 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)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ой это н правильно )

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так может выдутая совершенной другой currency_rate. было все верно. В чем именно проблема-то?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants