Skip to content

Commit

Permalink
Merge pull request #1457 from zmcNotafraid/issue-1437-2
Browse files Browse the repository at this point in the history
Issue 1437 2
  • Loading branch information
zmcNotafraid authored Jun 14, 2023
2 parents 7742d2a + 8dc1cad commit d9ea4a2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
6 changes: 5 additions & 1 deletion lib/godwoken_explorer/graphql/resolovers/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defmodule GodwokenExplorer.Graphql.Resolvers.Transaction do

@sorter_fields [:block_number, :index, :hash]
@default_sorter @sorter_fields
@account_tx_limit 100_000

def transaction(_parent, %{input: input} = _args, _resolution) do
query = query_with_eth_hash_or_tx_hash(input)
Expand Down Expand Up @@ -160,21 +161,24 @@ defmodule GodwokenExplorer.Graphql.Resolvers.Transaction do
{nil, to_account} ->
query
|> where([t], t.to_account_id == ^to_account.id)
|> limit(@account_tx_limit)

{from_account, nil} ->
query
|> where([t], t.from_account_id == ^from_account.id)
|> limit(@account_tx_limit)

{from_account, to_account} ->
if input[:combine_from_to] do
query_tx_hashes_by_account_type(query, from_account)
query |> query_tx_hashes_by_account_type(from_account)
else
query
|> where(
[t],
t.to_account_id == ^to_account.id and t.from_account_id == ^from_account.id
)
end
|> limit(@account_tx_limit)
end
end

Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ defmodule GodwokenExplorer.MixProject do
{:phoenix_html, "~> 3.3.0"},
{:phoenix_view, "~> 2.0"},
{:phoenix_live_reload, "~> 1.4.0", only: :dev},
{:phoenix_live_dashboard, "~> 0.7.2"},
{:phoenix_live_dashboard, "~> 0.8.0"},
{:esbuild, "~> 0.7", runtime: Mix.env() == :dev},
{:telemetry_metrics, "~> 0.6.1"},
{:telemetry_poller, "~> 1.0.0"},
Expand Down
Loading

0 comments on commit d9ea4a2

Please sign in to comment.