Remove unused transaction count query

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

@ -20,13 +20,6 @@ defmodule Explorer.Chain.Statistics do
) t
"""
@transaction_count_query """
SELECT count(transactions.hash)
FROM transactions
JOIN blocks ON blocks.hash = transactions.block_hash
WHERE blocks.timestamp > NOW() - interval '1 day'
"""
@lag_query """
SELECT coalesce(avg(lag), interval '0 seconds')
FROM (
@ -69,7 +62,6 @@ defmodule Explorer.Chain.Statistics do
* `number` - the latest `t:Explorer.Chain.Block.t/0` `number`
`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
* `transaction_velocity` - the number of `t:Explorer.Chain.Block.t/0` mined/validated in the last minute
* `transactions` - the last <= 5 `t:Explorer.Chain.Transaction.t/0`
"""
@ -80,7 +72,6 @@ defmodule Explorer.Chain.Statistics do
lag: Duration.t(),
number: Block.block_number(),
timestamp: :calendar.datetime(),
transaction_count: non_neg_integer(),
transaction_velocity: transactions_per_minute(),
transactions: [Transaction.t()]
}
@ -91,7 +82,6 @@ defmodule Explorer.Chain.Statistics do
lag: %Duration{seconds: 0, megaseconds: 0, microseconds: 0},
number: -1,
timestamp: nil,
transaction_count: 0,
transaction_velocity: 0,
transactions: []
@ -119,7 +109,6 @@ defmodule Explorer.Chain.Statistics do
block_velocity: query_value(@block_velocity_query),
blocks: Repo.all(blocks),
lag: query_duration(@lag_query),
transaction_count: query_value(@transaction_count_query),
transaction_velocity: query_value(@transaction_velocity_query),
transactions: transactions
}

@ -42,24 +42,6 @@ defmodule Explorer.Chain.StatisticsTest do
} = Statistics.fetch()
end
test "returns the count of transactions from blocks in the last day" do
time = DateTime.utc_now()
block = insert(:block, timestamp: time)
:transaction
|> insert()
|> with_block(block)
last_week = Timex.shift(time, days: -8)
old_block = insert(:block, timestamp: last_week)
:transaction
|> insert()
|> with_block(old_block)
assert %Statistics{transaction_count: 1} = Statistics.fetch()
end
test "returns the lag between validation and insertion time" do
validation_time = DateTime.utc_now()
inserted_at = validation_time |> Timex.shift(seconds: 5)

Loading…
Cancel
Save