Remove unused Chain.address_count function and format/credo appeasement

pull/511/head
Stamates 6 years ago
parent 36949da03b
commit ac166adac9
  1. 24
      apps/explorer/lib/explorer/chain.ex
  2. 3
      apps/explorer_web/lib/explorer_web/controllers/chain_controller.ex
  3. 3
      apps/explorer_web/test/explorer_web/features/viewing_chain_test.exs
  4. 2
      apps/explorer_web/test/support/fake_adapter.ex

@ -69,7 +69,7 @@ defmodule Explorer.Chain do
Estimated count of addresses
"""
@spec address_estimated_count() :: non_neg_integer()
@spec address_estimated_count :: non_neg_integer()
def address_estimated_count do
%Postgrex.Result{rows: [[rows]]} =
SQL.query!(Repo, "SELECT reltuples::BIGINT AS estimate FROM pg_class WHERE relname='addresses'")
@ -188,12 +188,11 @@ defmodule Explorer.Chain do
|> Repo.all()
end
@doc """
The average time it took to mine/validate the last <= 100 `t:Explorer.Chain.Block.t/0`
"""
@spec average_block_time() :: non_neg_integer()
def average_block_time() do
@spec average_block_time :: %Timex.Duration{}
def average_block_time do
{:ok, %Postgrex.Result{rows: [[rows]]}} =
SQL.query(
Repo,
@ -652,23 +651,6 @@ defmodule Explorer.Chain do
Import.all(options)
end
@doc """
The number of `t:Explorer.Chain.Address.t/0`.
iex> insert_list(2, :address)
iex> Explorer.Chain.address_count()
2
When there are no `t:Explorer.Chain.Address.t/0`, the count is `0`.
iex> Explorer.Chain.address_count()
0
"""
def address_count do
Repo.aggregate(Address, :count, :hash)
end
@doc """
The number of `t:Explorer.Chain.InternalTransaction.t/0`.

@ -1,8 +1,7 @@
defmodule ExplorerWeb.ChainController do
use ExplorerWeb, :controller
alias Explorer.{PagingOptions, Repo}
alias Explorer.Chain
alias Explorer.{Chain, PagingOptions, Repo}
alias Explorer.Chain.{Address, Block, Transaction}
alias Explorer.ExchangeRates.Token
alias Explorer.Market

@ -30,6 +30,7 @@ defmodule ExplorerWeb.ViewingChainTest do
describe "statistics" do
test "average block time live updates", %{session: session} do
time = DateTime.utc_now()
for x <- 100..0 do
insert(:block, timestamp: Timex.shift(time, seconds: -5 * x), number: x + 500)
end
@ -40,7 +41,7 @@ defmodule ExplorerWeb.ViewingChainTest do
block =
100..0
|> Enum.map(fn(index) ->
|> Enum.map(fn index ->
insert(:block, timestamp: Timex.shift(time, seconds: -10 * index), number: index + 800)
end)
|> hd()

@ -2,7 +2,7 @@ defmodule ExplorerWeb.FakeAdapter do
alias Explorer.Chain.Address
alias Explorer.Repo
def address_estimated_count() do
def address_estimated_count do
Repo.aggregate(Address, :count, :hash)
end
end

Loading…
Cancel
Save