Add a new route to top addresses view

pull/744/head
Ryan Arthur 6 years ago committed by Stamates
parent c9c62dcac2
commit 96898cec49
  1. 22
      apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex
  2. 2
      apps/block_scout_web/lib/block_scout_web/router.ex

@ -1,9 +1,31 @@
defmodule BlockScoutWeb.AddressController do
use BlockScoutWeb, :controller
import BlockScoutWeb.Chain, only: [paging_options: 1, next_page_params: 3, split_list_by_page: 1]
alias Explorer.Chain
alias Explorer.Chain.Address
def index(conn, params) do
full_options =
Keyword.merge(
[
necessity_by_association: %{
transactions: :optional
}
],
paging_options(params)
)
addresses_plus_one = []
# addresses_plus_one = Chain.list_top_addresses(full_options)
{addresses, next_page} = split_list_by_page(addresses_plus_one)
render(conn, "index.html", addresses: addresses, next_page_params: next_page_params(next_page, addresses, params))
end
def show(conn, %{"id" => id}) do
redirect(conn, to: address_transaction_path(conn, :index, id))
end

@ -61,6 +61,8 @@ defmodule BlockScoutWeb.Router do
resources("/token_transfers", TransactionTokenTransferController, only: [:index], as: :token_transfer)
end
resources("/top_addresses", AddressController, only: [:index])
resources "/address", AddressController, only: [:show] do
resources("/transactions", AddressTransactionController, only: [:index], as: :transaction)

Loading…
Cancel
Save