Speed-up query execution for weekly_new_token_transfers_number_query (#10289)

pull/10297/head
Victor Baranov 5 months ago committed by GitHub
parent d534902539
commit 8cb56f7551
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      apps/explorer/lib/explorer/chain/metrics/queries.ex

@ -8,6 +8,7 @@ defmodule Explorer.Chain.Metrics.Queries do
distinct: 2,
from: 2,
join: 4,
join: 5,
select: 3,
subquery: 1,
union: 2,
@ -127,7 +128,7 @@ defmodule Explorer.Chain.Metrics.Queries do
@spec weekly_new_token_transfers_number_query() :: Ecto.Query.t()
def weekly_new_token_transfers_number_query do
TokenTransfer
|> join(:inner, [tt], block in assoc(tt, :block))
|> join(:inner, [tt], block in Block, on: block.number == tt.block_number)
|> where([tt, block], block.timestamp >= ago(7, "day"))
|> where([tt, block], block.consensus == true)
|> select([tt, block], fragment("COUNT(*)"))

Loading…
Cancel
Save