Skip to content

Commit

Permalink
Added Trending
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny77D committed Aug 22, 2024
1 parent 3c24130 commit 85e3e07
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ with
ref("ez_near_metrics_by_category"),
ref("ez_optimism_metrics_by_category"),
ref("ez_polygon_metrics_by_category"),
ref("ez_sei_metrics_by_category"),
ref("ez_solana_metrics_by_category"),
ref("ez_sui_metrics_by_category"),
ref("ez_tron_metrics_by_category"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ with
ref("ez_near_metrics"),
ref("ez_optimism_metrics"),
ref("ez_polygon_metrics"),
ref("ez_sei_metrics"),
ref("ez_solana_metrics"),
ref("ez_sui_metrics"),
ref("ez_tron_metrics"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,24 @@ select
'polygon' as chain
from {{ ref("ez_polygon_metrics_by_contract") }}
union
select
contract_address,
date,
name,
null as symbol,
app as namespace,
friendly_name,
category,
gas as total_gas,
gas_usd as total_gas_usd,
txns as transactions,
dau,
null as token_transfer_usd,
null as token_transfer,
null as avg_token_price,
'sei' as chain
from {{ ref("ez_sei_metrics_by_contract") }}
union
select
contract_address,
date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ with
ref("ez_near_metrics_by_application"),
ref("ez_optimism_metrics_by_application"),
ref("ez_polygon_metrics_by_application"),
ref("ez_sei_metrics_by_application"),
ref("ez_solana_metrics_by_application"),
ref("ez_sui_metrics_by_application"),
ref("ez_tron_metrics_by_application"),
Expand Down
151 changes: 89 additions & 62 deletions models/staging/sei/fact_sei_transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,95 @@
snowflake_warehouse="SEI_LG",
)
}}
WITH transaction_data as (
SELECT
tx_hash,
status = 'SUCCESS' as success,
block_timestamp,
raw_date,
from_address,
tx_fee,
gas_usd,
contract_address,
name,
app,
friendly_name,
sub_category,
inserted_timestamp,
category,
user_type,
address_life_span,
cur_total_txns,
cur_distinct_to_address_count,
probability,
engagement_type,
balance_usd,
native_token_balance,
stablecoin_balance
FROM {{ ref("fact_sei_evm_transactions") }}
{% if is_incremental() %}
where
-- this filter will only be applied on an incremental run
inserted_timestamp
>= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }})
{% endif %}
UNION ALL
SELECT
tx_hash,
success,
block_timestamp,
raw_date,
signer as from_address,
tx_fee,
gas_usd,
contract_address,
name,
app,
friendly_name,
sub_category,
inserted_timestamp,
category,
user_type,
address_life_span,
cur_total_txns,
cur_distinct_to_address_count,
probability,
engagement_type,
balance_usd,
native_token_balance,
stablecoin_balance
FROM {{ ref("fact_sei_wasm_transactions") }}
{% if is_incremental() %}
where
-- this filter will only be applied on an incremental run
inserted_timestamp
>= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }})
{% endif %}
)
SELECT
tx_hash,
status = 'SUCCESS' as success,
block_timestamp,
raw_date,
from_address,
tx_fee,
gas_usd,
max(success) as success,
max(block_timestamp) as block_timestamp,
max(raw_date) as raw_date,
max(from_address) as from_address,
max(tx_fee) as tx_fee,
max(gas_usd) as gas_usd,
'sei' as chain,
contract_address,
name,
app,
friendly_name,
sub_category,
inserted_timestamp,
category,
user_type,
address_life_span,
cur_total_txns,
cur_distinct_to_address_count,
probability,
engagement_type,
balance_usd,
native_token_balance,
stablecoin_balance
FROM {{ ref("fact_sei_evm_transactions") }}
{% if is_incremental() %}
where
-- this filter will only be applied on an incremental run
inserted_timestamp
>= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }})
{% endif %}
UNION ALL
SELECT
tx_hash,
success,
block_timestamp,
raw_date,
signer as from_address,
tx_fee,
gas_usd,
'sei' as chain,
contract_address,
name,
app,
friendly_name,
sub_category,
inserted_timestamp,
category,
user_type,
address_life_span,
cur_total_txns,
cur_distinct_to_address_count,
probability,
engagement_type,
balance_usd,
native_token_balance,
stablecoin_balance
FROM {{ ref("fact_sei_wasm_transactions") }}
{% if is_incremental() %}
where
-- this filter will only be applied on an incremental run
inserted_timestamp
>= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }})
{% endif %}
max(contract_address) as contract_address,
max(name) as name,
max(app) as app,
max(friendly_name) as friendly_name,
max(sub_category) as sub_category,
max(inserted_timestamp) as inserted_timestamp,
max(category) as category,
max(user_type) as user_type,
max(address_life_span) as address_life_span,
max(cur_total_txns) as cur_total_txns,
max(cur_distinct_to_address_count) as cur_distinct_to_address_count,
max(probability) as probability,
max(engagement_type) as engagement_type,
max(balance_usd) as balance_usd,
max(native_token_balance) as native_token_balance,
max(stablecoin_balance) as stablecoin_balance
FROM transaction_data
GROUP BY tx_hash
2 changes: 1 addition & 1 deletion models/staging/sei/fact_sei_wasm_transactions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,5 @@ with
t1.block_timestamp < date(sysdate())
{% if is_incremental() %}
AND
inserted_timestamp >= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }})
t2.inserted_timestamp >= (select dateadd('day', -5, max(inserted_timestamp)) from {{ this }})
{% endif %}
6 changes: 6 additions & 0 deletions models/trending/bam_trending_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ union all
select *, 'polygon' as chain
from {{ ref("polygon_trending_weekly_monthly") }}
union all
select *, 'sei' as chain
from {{ ref("sei_trending_daily") }}
union all
select *, 'sei' as chain
from {{ ref("sei_trending_weekly_monthly") }}
union all
select *, 'solana' as chain
from {{ ref("solana_trending_daily") }}
union all
Expand Down

0 comments on commit 85e3e07

Please sign in to comment.