diff --git a/CHANGELOG.md b/CHANGELOG.md index ecd8e613a7..c85fd9904c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/apps/explorer/lib/explorer/counters/average_block_time.ex b/apps/explorer/lib/explorer/counters/average_block_time.ex index 6db9caf8f6..450d6b8fb0 100644 --- a/apps/explorer/lib/explorer/counters/average_block_time.ex +++ b/apps/explorer/lib/explorer/counters/average_block_time.ex @@ -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)