fix coin history chart data

pull/2528/head
Ayrat Badykov 5 years ago
parent 04cccd9ce6
commit 02bfc7e8dc
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 7
      apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_by_day_controller.ex
  2. 5
      apps/block_scout_web/test/block_scout_web/controllers/address_coin_balance_by_day_controller_test.exs

@ -9,7 +9,12 @@ defmodule BlockScoutWeb.AddressCoinBalanceByDayController do
def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"}) do def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"}) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string) do with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string) do
balances_by_day = Chain.address_to_balances_by_day(address_hash) balances_by_day =
address_hash
|> Chain.address_to_balances_by_day()
|> Enum.map(fn %{value: value} = map ->
Map.put(map, :value, Decimal.to_float(value))
end)
json(conn, balances_by_day) json(conn, balances_by_day)
end end

@ -14,7 +14,10 @@ defmodule BlockScoutWeb.AddressCoinBalanceByDayControllerTest do
response = json_response(conn, 200) response = json_response(conn, 200)
assert length(response) == 2 assert [
%{"date" => _, "value" => 2.0e-15},
%{"date" => _, "value" => 1.0e-15}
] = response
end end
end end
end end

Loading…
Cancel
Save