Skip to content

Commit

Permalink
Adapt explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmanzanera committed Oct 5, 2022
1 parent 9cbb375 commit b9ee5a0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions lib/archethic_web/live/chains/beacon_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ defmodule ArchethicWeb.BeaconChainLive do
use ArchethicWeb, :live_view

alias Archethic.BeaconChain
alias Archethic.BeaconChain.SummaryAggregate

alias Archethic.Election

Expand Down Expand Up @@ -208,10 +209,13 @@ defmodule ArchethicWeb.BeaconChainLive do
end

defp list_transactions_from_summary(date = %DateTime{}) do
[date]
|> BeaconChain.fetch_summary_aggregates()
|> Enum.flat_map(& &1.transaction_summaries)
|> Enum.sort_by(& &1.timestamp, {:desc, DateTime})
case BeaconChain.get_summaries_aggregate(date) do
{:ok, %SummaryAggregate{transaction_summaries: tx_summaries}} ->
Enum.sort_by(tx_summaries, & &1.timestamp, {:desc, DateTime})

_ ->
[]
end
end

defp list_transactions_from_summary(nil), do: []
Expand Down
14 changes: 9 additions & 5 deletions lib/archethic_web/live/top_transactions_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ defmodule ArchethicWeb.ExplorerIndexLive.TopTransactionsComponent do
use ArchethicWeb, :live_component

alias Archethic.BeaconChain
alias Archethic.BeaconChain.SummaryAggregate

alias Archethic.Election

Expand Down Expand Up @@ -59,7 +60,7 @@ defmodule ArchethicWeb.ExplorerIndexLive.TopTransactionsComponent do
txns |> push_txns_to_cache()
txns
else
TopTransactionsCache.get()
TopTransactionsCache.get() |> Enum.take(10)
end
end

Expand Down Expand Up @@ -184,9 +185,12 @@ defmodule ArchethicWeb.ExplorerIndexLive.TopTransactionsComponent do
end

defp list_transactions_from_summary(date = %DateTime{}) do
[date]
|> BeaconChain.fetch_summary_aggregates()
|> Enum.flat_map(& &1.transaction_summaries)
|> Enum.sort_by(& &1.timestamp, {:desc, DateTime})
case BeaconChain.get_summaries_aggregate(date) do
{:ok, %SummaryAggregate{transaction_summaries: tx_summaries}} ->
Enum.sort_by(tx_summaries, & &1.timestamp, {:desc, DateTime})

_ ->
[]
end
end
end

0 comments on commit b9ee5a0

Please sign in to comment.