Skip to content

Commit

Permalink
Fix sei dau count (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny77D authored Nov 22, 2024
1 parent 2af8b10 commit 481c371
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
40 changes: 18 additions & 22 deletions models/projects/sei/core/ez_sei_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,34 @@
)
}}
with
sei_fundamental_metrics as (select * from {{ ref("fact_sei_daa_txns_gas_gas_usd_revenue") }})
, rolling_metrics as ({{ get_rolling_active_address_metrics("sei_wasm") }})
sei_combined_fundamental_metrics as ( {{ get_fundamental_data_for_chain("sei") }} )
, sei_fundamental_metrics as (select * from {{ ref("fact_sei_daa_txns_gas_gas_usd_revenue") }})
, rolling_metrics as ({{ get_rolling_active_address_metrics("sei") }})
, sei_avg_block_time as (select * from {{ ref("fact_sei_avg_block_time_silver") }})
, price_data as ({{ get_coingecko_metrics("sei-network") }})
, defillama_data as ({{ get_defillama_metrics("sei") }})
, sei_evm_fundamental_metrics as (select * from {{ref("fact_sei_evm_fundamental_metrics_silver")}})
, sei_evm_avg_block_time as (select * from {{ ref("fact_sei_evm_avg_block_time_silver") }})
, rolling_evm_metrics as ({{ get_rolling_active_address_metrics("sei_evm") }})
select
coalesce(wasm.date, evm.date, sei_avg_block_time.date, price.date, defillama.date) as date
coalesce(combined.date, wasm.date, evm.date, sei_avg_block_time.date, price.date, defillama.date) as date
, (wasm_avg_block_time + evm_avg_block_time) / 2 as avg_block_time
, (wasm_txns + evm_txns) / 86400 as avg_tps
, 'sei' as chain
, wasm_txns + coalesce(evm_txns, 0) as txns
, wasm_daa + coalesce(evm_daa, 0) as dau
, wasm_new_users + coalesce(evm_new_users, 0) as new_users
, wasm_returning_users + coalesce(evm_returning_users, 0) as returning_users
, wasm_rolling_metrics.mau + evm_rolling_metrics.mau as mau
, wasm_rolling_metrics.wau + evm_rolling_metrics.wau as wau
, wasm_gas + coalesce(evm_gas, 0) as fees_native
, wasm_gas_usd + coalesce(evm_gas_usd, 0) as fees
, fees / txns as avg_txn_fee
, combined.txns as txns
, combined.dau as dau
, combined.new_users as new_users
, combined.returning_users as returning_users
, rolling_metrics.mau as mau
, rolling_metrics.wau as wau
, combined.fees_native as fees_native
, combined.fees as fees
, combined.avg_txn_fee as avg_txn_fee
, 0 as revenue_native
, 0 as revenue
, wasm_txns
, wasm_daa as wasm_dau
, wasm_returning_users
, wasm_new_users
, wasm_rolling_metrics.mau as wasm_mau
, wasm_rolling_metrics.wau as wasm_wau
, wasm_gas as wasm_fees_native
, wasm_gas_usd as wasm_fees
, wasm_avg_block_time as wasm_avg_block_time
Expand All @@ -51,20 +49,18 @@ select
, evm_returning_users
, evm_txns
, evm_daa as evm_dau
, evm_rolling_metrics.mau as evm_mau
, evm_rolling_metrics.wau as evm_wau
, evm_avg_tps
, evm_gas as evm_fees_native
, evm_gas_usd as evm_fees
, 0 as evm_revenue
, evm_avg_block_time
from sei_fundamental_metrics as wasm
full join rolling_metrics as wasm_rolling_metrics using (date)
from sei_combined_fundamental_metrics as combined
full join sei_fundamental_metrics as wasm using (date)
full join sei_evm_fundamental_metrics as evm using (date)
full join rolling_metrics using (date)
full join sei_avg_block_time as sei_avg_block_time using (date)
full join sei_evm_avg_block_time using (date)
full join price_data as price using (date)
full join defillama_data as defillama using (date)
full join sei_evm_fundamental_metrics as evm using (date)
full join rolling_evm_metrics as evm_rolling_metrics using (date)
where
coalesce(wasm.date, evm.date, sei_avg_block_time.date, price.date, defillama.date) < date(sysdate())
coalesce(combined.date, wasm.date, evm.date, sei_avg_block_time.date, price.date, defillama.date) < date(sysdate())
9 changes: 9 additions & 0 deletions models/staging/sei/fact_sei_rolling_active_addresses.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{
config(
materialized="incremental",
unique_key=["date"],
snowflake_warehouse="SEI",
)
}}

{{ rolling_active_addresses("sei") }}
13 changes: 13 additions & 0 deletions models/staging/sei/fact_sei_wasm_transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
)
}}
with
evm_txs AS (
select
distinct tx_id from sei_flipside.core.fact_msg_attributes
where
msg_type ='message' and attribute_key = 'action' and ATTRIBUTE_VALUE = '/seiprotocol.seichain.evm.MsgEVMTransaction'
{% if is_incremental() %}
AND inserted_timestamp >= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }})
{% endif %}
),
new_contracts as (
select distinct
address,
Expand Down Expand Up @@ -105,6 +114,10 @@ with
AND
t2.inserted_timestamp >= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }})
{% endif %}
AND tx_id NOT IN (
SELECT tx_id
FROM evm_txs e
)
)
SELECT
tx_hash
Expand Down

0 comments on commit 481c371

Please sign in to comment.