From 1b3a80b448ef253fcdff0b980fe649d1248f6761 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 27 May 2020 12:24:55 +0300 Subject: [PATCH] Fix performance of coin supply API endpoints --- CHANGELOG.md | 1 + apps/explorer/lib/explorer/chain.ex | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e1a97a65a..39968689cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features ### Fixes +- [#3132](https://github.com/poanetwork/blockscout/pull/3132) - Fix performance of coin supply API endpoints - [#3130](https://github.com/poanetwork/blockscout/pull/3130) - Take into account FIRST_BLOCK for block rewards fetching - [#3128](https://github.com/poanetwork/blockscout/pull/3128) - Token instance metadata retriever refinement: add processing of token metadata if only image URL is passed to token URI - [#3126](https://github.com/poanetwork/blockscout/pull/3126) - Fetch balance only for blocks which are greater or equal block with FIRST_BLOCK number diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 79650b48e7..f1d409a8f6 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1517,7 +1517,8 @@ defmodule Explorer.Chain do from( a0 in Address, select: fragment("SUM(a0.fetched_coin_balance)"), - where: a0.hash != ^burn_address_hash + where: a0.hash != ^burn_address_hash, + where: a0.fetched_coin_balance > 0 ) Repo.one!(query) || 0 @@ -1528,7 +1529,8 @@ defmodule Explorer.Chain do query = from( a0 in Address, - select: fragment("SUM(a0.fetched_coin_balance)") + select: fragment("SUM(a0.fetched_coin_balance)"), + where: a0.fetched_coin_balance > 0 ) Repo.one!(query) || 0