Remove unused skipped blocks query from `Expolorer.Chain.Statistics`

pull/336/head
Tim Mecklem 7 years ago
parent 2066427b29
commit 36b3f2af78
  1. 11
      apps/explorer/lib/explorer/chain/statistics.ex
  2. 9
      apps/explorer/test/explorer/chain/statistics_test.exs

@ -27,13 +27,6 @@ defmodule Explorer.Chain.Statistics do
WHERE blocks.timestamp > NOW() - interval '1 day' WHERE blocks.timestamp > NOW() - interval '1 day'
""" """
@skipped_blocks_query """
SELECT COUNT(missing_number)
FROM generate_series(0, $1, 1) AS missing_number
LEFT JOIN blocks ON missing_number = blocks.number
WHERE blocks.hash IS NULL
"""
@lag_query """ @lag_query """
SELECT coalesce(avg(lag), interval '0 seconds') SELECT coalesce(avg(lag), interval '0 seconds')
FROM ( FROM (
@ -74,7 +67,6 @@ defmodule Explorer.Chain.Statistics do
(`t:Explorer.Chain.Block.t/0` `timestamp`) and when it was inserted into the databasse (`t:Explorer.Chain.Block.t/0` `timestamp`) and when it was inserted into the databasse
(`t:Explorer.Chain.Block.t/0` `inserted_at`) (`t:Explorer.Chain.Block.t/0` `inserted_at`)
* `number` - the latest `t:Explorer.Chain.Block.t/0` `number` * `number` - the latest `t:Explorer.Chain.Block.t/0` `number`
* `skipped_blocks` - the number of blocks that were mined/validated, but do not exist as
`t:Explorer.Chain.Block.t/0` `t:Explorer.Chain.Block.t/0`
* `timestamp` - when the last `t:Explorer.Chain.Block.t/0` was mined/validated * `timestamp` - when the last `t:Explorer.Chain.Block.t/0` was mined/validated
* `transaction_count` - the number of transactions confirmed in blocks that were mined/validated in the last day * `transaction_count` - the number of transactions confirmed in blocks that were mined/validated in the last day
@ -87,7 +79,6 @@ defmodule Explorer.Chain.Statistics do
blocks: [Block.t()], blocks: [Block.t()],
lag: Duration.t(), lag: Duration.t(),
number: Block.block_number(), number: Block.block_number(),
skipped_blocks: non_neg_integer(),
timestamp: :calendar.datetime(), timestamp: :calendar.datetime(),
transaction_count: non_neg_integer(), transaction_count: non_neg_integer(),
transaction_velocity: transactions_per_minute(), transaction_velocity: transactions_per_minute(),
@ -99,7 +90,6 @@ defmodule Explorer.Chain.Statistics do
blocks: [], blocks: [],
lag: %Duration{seconds: 0, megaseconds: 0, microseconds: 0}, lag: %Duration{seconds: 0, megaseconds: 0, microseconds: 0},
number: -1, number: -1,
skipped_blocks: 0,
timestamp: nil, timestamp: nil,
transaction_count: 0, transaction_count: 0,
transaction_velocity: 0, transaction_velocity: 0,
@ -142,7 +132,6 @@ defmodule Explorer.Chain.Statistics do
%__MODULE__{ %__MODULE__{
state state
| number: number, | number: number,
skipped_blocks: query_value(@skipped_blocks_query, [number]),
timestamp: timestamp timestamp: timestamp
} }

@ -60,15 +60,6 @@ defmodule Explorer.Chain.StatisticsTest do
assert %Statistics{transaction_count: 1} = Statistics.fetch() assert %Statistics{transaction_count: 1} = Statistics.fetch()
end end
test "returns the number of skipped blocks" do
insert(:block, %{number: 0})
insert(:block, %{number: 2})
statistics = Statistics.fetch()
assert statistics.skipped_blocks == 1
end
test "returns the lag between validation and insertion time" do test "returns the lag between validation and insertion time" do
validation_time = DateTime.utc_now() validation_time = DateTime.utc_now()
inserted_at = validation_time |> Timex.shift(seconds: 5) inserted_at = validation_time |> Timex.shift(seconds: 5)

Loading…
Cancel
Save