From 36b3f2af78d4e8f901b66379b816ab6f685ef45c Mon Sep 17 00:00:00 2001 From: Tim Mecklem Date: Mon, 25 Jun 2018 13:29:51 -0400 Subject: [PATCH] Remove unused skipped blocks query from `Expolorer.Chain.Statistics` --- apps/explorer/lib/explorer/chain/statistics.ex | 11 ----------- apps/explorer/test/explorer/chain/statistics_test.exs | 9 --------- 2 files changed, 20 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/statistics.ex b/apps/explorer/lib/explorer/chain/statistics.ex index 23af3b1eb4..2a09b864af 100644 --- a/apps/explorer/lib/explorer/chain/statistics.ex +++ b/apps/explorer/lib/explorer/chain/statistics.ex @@ -27,13 +27,6 @@ defmodule Explorer.Chain.Statistics do 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 """ SELECT coalesce(avg(lag), interval '0 seconds') 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` `inserted_at`) * `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` * `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 @@ -87,7 +79,6 @@ defmodule Explorer.Chain.Statistics do blocks: [Block.t()], lag: Duration.t(), number: Block.block_number(), - skipped_blocks: non_neg_integer(), timestamp: :calendar.datetime(), transaction_count: non_neg_integer(), transaction_velocity: transactions_per_minute(), @@ -99,7 +90,6 @@ defmodule Explorer.Chain.Statistics do blocks: [], lag: %Duration{seconds: 0, megaseconds: 0, microseconds: 0}, number: -1, - skipped_blocks: 0, timestamp: nil, transaction_count: 0, transaction_velocity: 0, @@ -142,7 +132,6 @@ defmodule Explorer.Chain.Statistics do %__MODULE__{ state | number: number, - skipped_blocks: query_value(@skipped_blocks_query, [number]), timestamp: timestamp } diff --git a/apps/explorer/test/explorer/chain/statistics_test.exs b/apps/explorer/test/explorer/chain/statistics_test.exs index 1338a3b2e5..342698e009 100644 --- a/apps/explorer/test/explorer/chain/statistics_test.exs +++ b/apps/explorer/test/explorer/chain/statistics_test.exs @@ -60,15 +60,6 @@ defmodule Explorer.Chain.StatisticsTest do assert %Statistics{transaction_count: 1} = Statistics.fetch() 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 validation_time = DateTime.utc_now() inserted_at = validation_time |> Timex.shift(seconds: 5)