Skip to content

Commit

Permalink
Hide "We are indexing this chain right now. Some of the counts may be…
Browse files Browse the repository at this point in the history
… inaccurate" banner if no txs in blockchain
  • Loading branch information
vbaranov committed Oct 21, 2019
1 parent 7315441 commit 3103b3a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- [#2470](https://github.com/poanetwork/blockscout/pull/2470) - Allow Realtime Fetcher to wait for small skips

### Fixes
- [#2793](https://github.com/poanetwork/blockscout/pull/2793) - Hide "We are indexing this chain right now. Some of the counts may be inaccurate" banner if no txs in blockchain
- [#2779](https://github.com/poanetwork/blockscout/pull/2779) - fix fetching `latin1` encoded data
- [#2783](https://github.com/poanetwork/blockscout/pull/2783) - Fix stuck value and ticker on the token page
- [#2781](https://github.com/poanetwork/blockscout/pull/2781) - optimize txlist json rpc
Expand Down
25 changes: 17 additions & 8 deletions apps/explorer/lib/explorer/chain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -715,19 +715,28 @@ defmodule Explorer.Chain do
"""
@spec finished_indexing?() :: boolean()
def finished_indexing? do
min_block_number_transaction = Repo.aggregate(Transaction, :min, :block_number)

if min_block_number_transaction do
transaction_exists =
Transaction
|> where([t], t.block_number == ^min_block_number_transaction and is_nil(t.internal_transactions_indexed_at))
|> limit(1)
|> Repo.one()
|> case do
nil -> true
_ -> false

min_block_number_transaction = Repo.aggregate(Transaction, :min, :block_number)

if transaction_exists do
if min_block_number_transaction do
Transaction
|> where([t], t.block_number == ^min_block_number_transaction and is_nil(t.internal_transactions_indexed_at))
|> limit(1)
|> Repo.one()
|> case do
nil -> true
_ -> false
end
else
false
end
else
false
true
end
end

Expand Down
6 changes: 6 additions & 0 deletions apps/explorer/test/explorer/chain_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,12 @@ defmodule Explorer.ChainTest do
assert Chain.finished_indexing?()
end

test "finished indexing (no txs)" do
block = insert(:block, number: 1)

assert Chain.finished_indexing?()
end

test "not finished indexing" do
block = insert(:block, number: 1)

Expand Down

0 comments on commit 3103b3a

Please sign in to comment.