From 421262a2da057223ea74b50909572e2eb2ea5e9a Mon Sep 17 00:00:00 2001 From: William Sanches Date: Fri, 16 Nov 2018 14:24:46 -0200 Subject: [PATCH] Fix credo and format issues --- apps/explorer/lib/explorer/chain.ex | 2 +- apps/explorer/lib/explorer/chain/token.ex | 2 +- apps/explorer/test/explorer/chain_test.exs | 2 +- apps/indexer/lib/indexer/token/metadata_updater.ex | 7 +++++-- apps/indexer/lib/indexer/token/supervisor.ex | 1 + 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index d79126f9dd..a2a55dcbd5 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1951,7 +1951,7 @@ defmodule Explorer.Chain do Repo.transaction( fn -> Chain.Token.cataloged_tokens() - |> Ecto.Query.order_by([asc: :updated_at]) + |> order_by(asc: :updated_at) |> Repo.stream(timeout: :infinity) |> Enum.reduce(initial_acc, reducer) end, diff --git a/apps/explorer/lib/explorer/chain/token.ex b/apps/explorer/lib/explorer/chain/token.ex index 306ded7856..22ba6d2504 100644 --- a/apps/explorer/lib/explorer/chain/token.ex +++ b/apps/explorer/lib/explorer/chain/token.ex @@ -100,7 +100,7 @@ defmodule Explorer.Chain.Token do These are tokens with cataloged field set to true. """ - def cataloged_tokens() do + def cataloged_tokens do from( token in __MODULE__, select: token.contract_address_hash, diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs index 2feb6aeddc..13c0f44906 100644 --- a/apps/explorer/test/explorer/chain_test.exs +++ b/apps/explorer/test/explorer/chain_test.exs @@ -2773,7 +2773,7 @@ defmodule Explorer.ChainTest do expected_response = [token1, token2] |> Enum.sort(&(&1.updated_at < &2.updated_at)) - |> Enum.map(&(&1.contract_address_hash)) + |> Enum.map(& &1.contract_address_hash) assert Chain.stream_cataloged_token_contract_address_hashes([], &(&2 ++ [&1])) == {:ok, expected_response} end diff --git a/apps/indexer/lib/indexer/token/metadata_updater.ex b/apps/indexer/lib/indexer/token/metadata_updater.ex index b7135dd1e8..6c3e0f1357 100644 --- a/apps/indexer/lib/indexer/token/metadata_updater.ex +++ b/apps/indexer/lib/indexer/token/metadata_updater.ex @@ -22,8 +22,11 @@ defmodule Indexer.Token.MetadataUpdater do @impl true def handle_info(:update_tokens, state) do - {:ok, tokens} = Chain.stream_cataloged_token_contract_address_hashes([], &(&2 ++ [&1])) - update_metadata(tokens) + {:ok, tokens} = Chain.stream_cataloged_token_contract_address_hashes([], &[&1 | &2]) + + tokens + |> Enum.reverse() + |> update_metadata() Process.send_after(self(), :update_tokens, :timer.hours(state.update_interval) * 24) diff --git a/apps/indexer/lib/indexer/token/supervisor.ex b/apps/indexer/lib/indexer/token/supervisor.ex index d50184371b..2e7d1b6360 100644 --- a/apps/indexer/lib/indexer/token/supervisor.ex +++ b/apps/indexer/lib/indexer/token/supervisor.ex @@ -28,6 +28,7 @@ defmodule Indexer.Token.Supervisor do @impl Supervisor def init(fetcher_arguments) do metadata_updater_inverval = Application.get_env(:indexer, :metadata_updater_days_interval) + Supervisor.init( [ {Task.Supervisor, name: Indexer.Token.TaskSupervisor},