Skip to content

Commit

Permalink
Revert "fix: filter out balances without day."
Browse files Browse the repository at this point in the history
This reverts commit 49edf1b.
  • Loading branch information
DenSmolonski committed Jul 5, 2024
1 parent 49edf1b commit f1865de
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions apps/indexer/lib/indexer/block/realtime/fetcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,10 @@ defmodule Indexer.Block.Realtime.Fetcher do
block_timestamp_map = CoinBalance.block_timestamp_map(params_list, json_rpc_named_arguments)

importable_balances_daily_params =
params_list
|> Enum.map(fn param ->
Enum.map(params_list, fn param ->
day = Map.get(block_timestamp_map, "#{param.block_number}")
(day && Map.put(param, :day, day)) || param
end)
|> Enum.filter(fn param -> Map.has_key?(param, :day) end)

{:ok,
%{
Expand Down
12 changes: 12 additions & 0 deletions apps/indexer/lib/indexer/fetcher/coin_balance_daily_updater.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,24 @@ defmodule Indexer.Fetcher.CoinBalanceDailyUpdater do
{:noreply, Enum.reduce(daily_balances_params, state, &put_new_param/2)}
end

# Clause to handle params without a :day key
defp put_new_param(%{day: nil} = param, acc) do
IO.inspect(param)
acc
end

defp put_new_param(%{day: day, address_hash: address_hash, value: value} = param, acc) do
Map.update(acc, {address_hash, day}, param, fn %{value: old_value} = old_param ->
if is_nil(old_value) or value > old_value, do: param, else: old_param
end)
end

# Default clause to catch all other cases
defp put_new_param(param, acc) do
IO.inspect(param, label: "Unhandled param structure")
acc
end

@impl true
def handle_info(:update, state) when state == %{} do
schedule_next_update()
Expand Down

0 comments on commit f1865de

Please sign in to comment.