diff --git a/api/src/presentation/event_listeners/quote_syncer.rs b/api/src/presentation/event_listeners/quote_syncer.rs index f6aa8dacff..984b81263d 100644 --- a/api/src/presentation/event_listeners/quote_syncer.rs +++ b/api/src/presentation/event_listeners/quote_syncer.rs @@ -5,7 +5,7 @@ use async_trait::async_trait; use chrono::Utc; use derive_more::Constructor; use domain::{currencies, services::quotes, BudgetEvent, Event, SubscriberCallbackError}; -use infrastructure::dbclient::Repository; +use infrastructure::{database::enums::Currency, dbclient::Repository}; use tracing::instrument; use super::EventListener; @@ -24,9 +24,9 @@ impl EventListener for Projector { if let Event::Budget(event) = event { match event { BudgetEvent::Created { currency, .. } if currency != currencies::USD => { - let code = currency.try_into()?; + let code: Currency = currency.try_into()?; - if !self.quotes_repository.exists(code)? { + if code.has_usd_equivalent() && !self.quotes_repository.exists(code)? { let price = self .quote_service .fetch_conversion_rate(currency) diff --git a/common/infrastructure/src/database/enums/currency.rs b/common/infrastructure/src/database/enums/currency.rs index f61c650795..e75ce2b0e6 100644 --- a/common/infrastructure/src/database/enums/currency.rs +++ b/common/infrastructure/src/database/enums/currency.rs @@ -12,6 +12,18 @@ pub enum Currency { Stark, } +impl Currency { + pub fn has_usd_equivalent(&self) -> bool { + match self { + Currency::Usd => false, + Currency::Eth => true, + Currency::Op => true, + Currency::Apt => true, + Currency::Stark => false, + } + } +} + impl TryFrom<&'static domain::Currency> for Currency { type Error = ParseCurrencyError;