fix remaining case warnings

pull/2432/head
Ayrat Badykov 5 years ago
parent e2088cac90
commit d426b2f758
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 24
      apps/block_scout_web/lib/block_scout_web/chain.ex
  2. 46
      apps/block_scout_web/lib/block_scout_web/controllers/recent_transactions_controller.ex
  3. 28
      apps/indexer/lib/indexer/fetcher/internal_transaction.ex

@ -124,18 +124,20 @@ defmodule BlockScoutWeb.Chain do
end
def paging_options(%{"block_number" => block_number_string}) do
with {block_number, ""} <- Integer.parse(block_number_string) do
[paging_options: %{@default_paging_options | key: {block_number}}]
else
case Integer.parse(block_number_string) do
{block_number, ""} ->
[paging_options: %{@default_paging_options | key: {block_number}}]
_ ->
[paging_options: @default_paging_options]
end
end
def paging_options(%{"index" => index_string}) when is_binary(index_string) do
with {index, ""} <- Integer.parse(index_string) do
[paging_options: %{@default_paging_options | key: {index}}]
else
case Integer.parse(index_string) do
{index, ""} ->
[paging_options: %{@default_paging_options | key: {index}}]
_ ->
[paging_options: @default_paging_options]
end
@ -174,10 +176,12 @@ defmodule BlockScoutWeb.Chain do
def split_list_by_page(list_plus_one), do: Enum.split(list_plus_one, @page_size)
defp address_from_param(param) do
with {:ok, hash} <- string_to_address_hash(param) do
find_or_insert_address_from_hash(hash)
else
:error -> {:error, :not_found}
case string_to_address_hash(param) do
{:ok, hash} ->
find_or_insert_address_from_hash(hash)
:error ->
{:error, :not_found}
end
end

@ -6,30 +6,32 @@ defmodule BlockScoutWeb.RecentTransactionsController do
alias Phoenix.View
def index(conn, _params) do
with true <- ajax?(conn) do
recent_transactions =
Chain.recent_collated_transactions(
necessity_by_association: %{
:block => :required,
[created_contract_address: :names] => :optional,
[from_address: :names] => :optional,
[to_address: :names] => :optional
},
paging_options: %PagingOptions{page_size: 5}
)
case ajax?(conn) do
true ->
recent_transactions =
Chain.recent_collated_transactions(
necessity_by_association: %{
:block => :required,
[created_contract_address: :names] => :optional,
[from_address: :names] => :optional,
[to_address: :names] => :optional
},
paging_options: %PagingOptions{page_size: 5}
)
transactions =
Enum.map(recent_transactions, fn transaction ->
%{
transaction_hash: Hash.to_string(transaction.hash),
transaction_html:
View.render_to_string(BlockScoutWeb.TransactionView, "_tile.html", transaction: transaction)
}
end)
transactions =
Enum.map(recent_transactions, fn transaction ->
%{
transaction_hash: Hash.to_string(transaction.hash),
transaction_html:
View.render_to_string(BlockScoutWeb.TransactionView, "_tile.html", transaction: transaction)
}
end)
json(conn, %{transactions: transactions})
else
_ -> unprocessable_entity(conn)
json(conn, %{transactions: transactions})
_ ->
unprocessable_entity(conn)
end
end
end

@ -188,20 +188,20 @@ defmodule Indexer.Fetcher.InternalTransaction do
{hash, block_number}
end)
with {:ok, imported} <-
Chain.import(%{
addresses: %{params: addresses_params},
internal_transactions: %{params: internal_transactions_params_without_failed_creations},
internal_transactions_indexed_at_blocks: %{
params: internal_transactions_indexed_at_blocks,
with: :number_only_changeset
},
timeout: :infinity
}) do
async_import_coin_balances(imported, %{
address_hash_to_fetched_balance_block_number: address_hash_to_block_number
})
else
case Chain.import(%{
addresses: %{params: addresses_params},
internal_transactions: %{params: internal_transactions_params_without_failed_creations},
internal_transactions_indexed_at_blocks: %{
params: internal_transactions_indexed_at_blocks,
with: :number_only_changeset
},
timeout: :infinity
}) do
{:ok, imported} ->
async_import_coin_balances(imported, %{
address_hash_to_fetched_balance_block_number: address_hash_to_block_number
})
{:error, step, reason, _changes_so_far} ->
Logger.error(
fn ->

Loading…
Cancel
Save