|
|
|
@ -19,6 +19,7 @@ defmodule Explorer.Chain.Metrics.Queries do |
|
|
|
|
|
|
|
|
|
alias Explorer.Chain.{ |
|
|
|
|
Address, |
|
|
|
|
Block, |
|
|
|
|
DenormalizationHelper, |
|
|
|
|
InternalTransaction, |
|
|
|
|
SmartContract, |
|
|
|
@ -135,7 +136,27 @@ defmodule Explorer.Chain.Metrics.Queries do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@doc """ |
|
|
|
|
Retrieves the query for the number of active EOA and smart-contract addresses in the current week. |
|
|
|
|
Retrieves the query for the number of addresses initiated transactions in the current week. |
|
|
|
|
""" |
|
|
|
|
@spec weekly_simplified_active_addresses_number_query() :: Ecto.Query.t() |
|
|
|
|
def weekly_simplified_active_addresses_number_query do |
|
|
|
|
if DenormalizationHelper.transactions_denormalization_finished?() do |
|
|
|
|
Transaction |
|
|
|
|
|> where([tx], tx.block_timestamp >= ago(7, "day")) |
|
|
|
|
|> where([tx], tx.block_consensus == true) |
|
|
|
|
|> select([tx], fragment("COUNT(DISTINCT(?))", tx.from_address_hash)) |
|
|
|
|
else |
|
|
|
|
Transaction |
|
|
|
|
|> join(:inner, [tx], block in assoc(tx, :block)) |
|
|
|
|
|> where([tx, block], block.timestamp >= ago(7, "day")) |
|
|
|
|
|> where([tx, block], block.consensus == true) |
|
|
|
|
|> select([tx], fragment("COUNT(DISTINCT(?))", tx.from_address_hash)) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
@doc """ |
|
|
|
|
Retrieves the query for the number of active EOA and smart-contract addresses (from/to/contract participated in transactions, internal transactions, token transfers) in the current week. |
|
|
|
|
This query is currently unused since the very low performance: it doesn't return results in 1 hour. |
|
|
|
|
""" |
|
|
|
|
@spec weekly_active_addresses_number_query() :: Ecto.Query.t() |
|
|
|
|
def weekly_active_addresses_number_query do |
|
|
|
|