Skip to content

Commit

Permalink
Fixed Ton models
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny77D committed Aug 13, 2024
1 parent fb6ef2b commit 3a61d04
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 3 additions & 2 deletions models/projects/ton/core/ez_ton_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ with
date,
txns as transaction_nodes
from {{ ref("fact_ton_daa_txns_gas_gas_usd_revenue_revenue_native") }}
), ton_apps_fundamental_data as (
),
ton_apps_fundamental_data as (
select
date,
date
, dau
, fees_native
, txns
Expand Down
10 changes: 7 additions & 3 deletions models/staging/ton/fact_ton_fundamental_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@

with flatten_ton_transaction as (
select
true = all(array_agg(success)) as success
NOT ARRAY_CONTAINS(0, ARRAY_UNIQUE_AGG(success)) as success
, trace_id
, max(block_timestamp::date) as date
, min_by(transaction_account_interfaces, lt)[1] as interface
, min_by(transaction_account_interfaces, lt) as interfaces
, min_by(transaction_account, lt) as first_account
, min_by(transaction_account_workchain, lt) as workchain
, sum(total_fees) as transaction_fees
from {{ ref('fact_ton_transactions') }}
{% if is_incremental() %}
where block_timestamp::date > (select dateadd('day', -3, max(date)) from {{ this }})
{% endif %}
group by trace_id
), txns as (
SELECT
Expand All @@ -34,7 +37,8 @@ dau as (
date
, count(distinct first_account) as dau
from flatten_ton_transaction
where success and interface like 'wallet_v%'
where success and interfaces[1] like 'wallet_v%'
group by date
)
SELECT
coalesce(fees.date, txns.date, dau.date) as date
Expand Down
1 change: 1 addition & 0 deletions models/staging/ton/fact_ton_transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ with raw_data as (
{{ source("PROD_LANDING", "raw_ton_transactions") }}
{% if is_incremental() %}
where TO_TIMESTAMP(parse_json(source_json):"utime") > (select dateadd('day', -3, max(block_timestamp)) from {{ this }})
and extraction_date > (select dateadd('day', -3, max(block_timestamp)) from {{ this }})
{% endif %}
)
select
Expand Down

0 comments on commit 3a61d04

Please sign in to comment.