From 75145508b18e0d1c99cf778e5999fda423701866 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Mon, 1 Jun 2020 23:16:17 +0300 Subject: [PATCH] Refine processing of balance by day --- apps/explorer/lib/explorer/chain.ex | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index ea3ace7278..481ae4a730 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/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)