diff --git a/Cargo.lock b/Cargo.lock index b87861c5a2..b067ecd372 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7135,7 +7135,7 @@ dependencies = [ [[package]] name = "nyx-chain-watcher" -version = "0.1.10" +version = "0.1.11" dependencies = [ "anyhow", "async-trait", diff --git a/nyx-chain-watcher/Cargo.toml b/nyx-chain-watcher/Cargo.toml index cfedca090d..318ba446ec 100644 --- a/nyx-chain-watcher/Cargo.toml +++ b/nyx-chain-watcher/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "nyx-chain-watcher" -version = "0.1.10" +version = "0.1.11" authors.workspace = true repository.workspace = true homepage.workspace = true diff --git a/nyx-chain-watcher/src/db/queries/price.rs b/nyx-chain-watcher/src/db/queries/price.rs index d3b371e2c4..4a6ddbeea3 100644 --- a/nyx-chain-watcher/src/db/queries/price.rs +++ b/nyx-chain-watcher/src/db/queries/price.rs @@ -61,8 +61,6 @@ pub(crate) async fn get_average_price(pool: &DbPool) -> anyhow::Result anyhow::Result 0f64 { - price.chf /= count; - price.usd /= count; - price.eur /= count; - price.gbp /= count; - price.btc /= count; + if chf_count > 0 { + price.chf /= chf_count as f64; + } + if usd_count > 0 { + price.usd /= usd_count as f64; + } + if eur_count > 0 { + price.eur /= eur_count as f64; + } + if gbp_count > 0 { + price.gbp /= gbp_count as f64; + } + if btc_count > 0 { + price.btc /= btc_count as f64; } Ok(price)