Refine processing of balance by day

pull/3125/head
Victor Baranov 5 years ago
parent 83156769f6
commit 75145508b1
  1. 3
      apps/explorer/lib/explorer/chain.ex

@ -3522,7 +3522,7 @@ defmodule Explorer.Chain do
address_hash
|> CoinBalanceDaily.balances_by_day()
|> Repo.all()
|> Enum.sort(&(&1.date <= &2.date))
|> Enum.sort_by(fn %{date: d} -> {d.year, d.month, d.day} end)
|> replace_last_value(latest_block_timestamp)
|> normalize_balances_by_day()
end
@ -3537,7 +3537,6 @@ defmodule Explorer.Chain do
defp normalize_balances_by_day(balances_by_day) do
result =
balances_by_day
|> Enum.map(fn day -> Map.take(day, [:date, :value]) end)
|> Enum.filter(fn day -> day.value end)
|> Enum.map(fn day -> Map.update!(day, :date, &to_string(&1)) end)
|> Enum.map(fn day -> Map.update!(day, :value, &Wei.to(&1, :ether)) end)

Loading…
Cancel
Save