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. 4
      apps/explorer_web/assets/js/pages/chain.js
  3. 2
      apps/explorer_web/lib/explorer_web/channels/address_channel.ex
  4. 3
      apps/explorer_web/lib/explorer_web/controllers/chain_controller.ex
  5. 2
      apps/explorer_web/lib/explorer_web/notifier.ex
  6. 3
      apps/explorer_web/test/explorer_web/features/viewing_chain_test.exs
  7. 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`.

@ -88,10 +88,10 @@ router.when('', { exactPathMatch: true }).then(({ locale }) => initRedux(reducer
const $transactionCount = $('[data-selector="transaction-count"]')
if (oldState.addressCount !== state.addressCount) {
$addressCount.empty().append(state.addressCount)
$addressCount.empty().append(state.addressCount)
}
if (oldState.averageBlockTime !== state.averageBlockTime) {
$averageBlockTime.empty().append(state.averageBlockTime)
$averageBlockTime.empty().append(state.averageBlockTime)
}
if (oldState.newBlock !== state.newBlock) {
$blockList.children().last().remove()

@ -40,7 +40,7 @@ defmodule ExplorerWeb.AddressChannel do
{:noreply, socket}
end
def handle_out("transaction", %{address: address, transaction: transaction}, socket) do
Gettext.put_locale(ExplorerWeb.Gettext, socket.assigns.locale)

@ -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

@ -48,7 +48,7 @@ defmodule ExplorerWeb.Notifier do
Endpoint.broadcast("blocks:new_block", "new_block", %{
block: preloaded_block,
average_block_time: Chain.average_block_time()
})
})
end
defp broadcast_transaction(transaction) do

@ -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