Transactions stats: get min/max blocks in one query

pull/4231/head
Viktor Baranov 4 years ago
parent 058b596b0c
commit e81ff7bf48
  1. 1
      CHANGELOG.md
  2. 20
      apps/explorer/lib/explorer/chain/transaction/history/historian.ex

@ -14,6 +14,7 @@
- [#3888](https://github.com/blockscout/blockscout/pull/3888) - EIP-1967 contract proxy pattern detection fix
### Chore
- [#4231](https://github.com/blockscout/blockscout/pull/4231) - Transactions stats: get min/max blocks in one query
- [#4157](https://github.com/blockscout/blockscout/pull/4157) - Fix internal docs generation
- [#4127](https://github.com/blockscout/blockscout/pull/4127) - Update ex_keccak package
- [#4063](https://github.com/blockscout/blockscout/pull/4063) - Do not display 4bytes signature in the tx tile for contract creation

@ -25,27 +25,13 @@ defmodule Explorer.Chain.Transaction.History.Historian do
earliest = datetime(day_to_fetch, ~T[00:00:00])
latest = datetime(day_to_fetch, ~T[23:59:59])
min_block_query =
min_max_block_query =
from(block in Block,
where: block.timestamp >= ^earliest and block.timestamp <= ^latest,
group_by: block.number,
order_by: [asc: min(block.number)],
limit: 1,
select: min(block.number)
select: {min(block.number), max(block.number)}
)
min_block = Repo.one(min_block_query, timeout: :infinity)
max_block_query =
from(block in Block,
where: block.timestamp >= ^earliest and block.timestamp <= ^latest,
group_by: block.number,
order_by: [desc: max(block.number)],
limit: 1,
select: max(block.number)
)
max_block = Repo.one(max_block_query, timeout: :infinity)
{min_block, max_block} = Repo.one(min_max_block_query, timeout: :infinity)
if min_block && max_block do
all_transactions_query =

Loading…
Cancel
Save