Merge pull request #2248 from poanetwork/ab-sort-blocks-after-query

sort block after query execution for average block time
pull/2267/head
Ayrat Badykov 6 years ago committed by GitHub
commit 3824de8691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 3
      apps/explorer/lib/explorer/counters/average_block_time.ex

@ -55,6 +55,7 @@
- [#2167](https://github.com/poanetwork/blockscout/pull/2167) - feat: document eth rpc api mimicking endpoints
- [#2225](https://github.com/poanetwork/blockscout/pull/2225) - fix metadata decoding in Solidity 0.5.9 smart contract verification
- [#2204](https://github.com/poanetwork/blockscout/pull/2204) - fix large contract verification
- [#2248](https://github.com/poanetwork/blockscout/pull/2248) - sort block after query execution for average block time
### Chore
- [#2127](https://github.com/poanetwork/blockscout/pull/2127) - use previouse chromedriver version

@ -66,13 +66,14 @@ defmodule Explorer.Counters.AverageBlockTime do
from(block in Block,
limit: 100,
offset: 0,
order_by: [desc: block.number, desc: block.timestamp],
order_by: [desc: block.number],
select: {block.number, block.timestamp}
)
timestamps =
timestamps_query
|> Repo.all()
|> Enum.sort_by(fn {_, timestamp} -> timestamp end, &>=/2)
|> Enum.map(fn {number, timestamp} ->
{number, DateTime.to_unix(timestamp, :millisecond)}
end)

Loading…
Cancel
Save