parent
d537280366
commit
b819733bf2
@ -1,32 +1,9 @@ |
|||||||
defmodule ExplorerWeb.ChainController do |
defmodule ExplorerWeb.ChainController do |
||||||
use ExplorerWeb, :controller |
use ExplorerWeb, :controller |
||||||
|
|
||||||
import Ecto.Query |
|
||||||
|
|
||||||
alias Explorer.Block |
|
||||||
alias Explorer.BlockForm |
|
||||||
alias Explorer.Servers.ChainStatistics |
alias Explorer.Servers.ChainStatistics |
||||||
alias Explorer.Repo.NewRelic, as: Repo |
|
||||||
alias Explorer.Transaction |
|
||||||
|
|
||||||
def show(conn, _params) do |
def show(conn, _params) do |
||||||
blocks = from block in Block, |
render(conn, "show.html", chain: ChainStatistics.fetch()) |
||||||
order_by: [desc: block.number], |
|
||||||
preload: :transactions, |
|
||||||
limit: 5 |
|
||||||
|
|
||||||
transactions = from transaction in Transaction, |
|
||||||
join: block in assoc(transaction, :block), |
|
||||||
order_by: [desc: block.number], |
|
||||||
preload: [block: block], |
|
||||||
limit: 5 |
|
||||||
|
|
||||||
render( |
|
||||||
conn, |
|
||||||
"show.html", |
|
||||||
blocks: blocks |> Repo.all() |> Enum.map(&BlockForm.build/1), |
|
||||||
transactions: transactions |> Repo.all(), |
|
||||||
chain: ChainStatistics.fetch() |
|
||||||
) |
|
||||||
end |
end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue