From c69336aae3090da9ad8b3ae86c3d61c16e3f22af Mon Sep 17 00:00:00 2001 From: SebMelendez01 <78228475+SebMelendez01@users.noreply.github.com> Date: Wed, 18 Dec 2024 22:57:46 -0500 Subject: [PATCH] Updating wrapped models (#689) --- .../artemis_wrapped/dim_artemis_wrapped.sql | 18 +++++------ .../metrics/agg_artemis_wrapped_metrics.sql | 14 +++++++- ...e_artemis_wrapped_metrics_with_percent.sql | 32 ++++++++++++------- ...a_artemis_wrapped_metrics_with_percent.sql | 32 ++++++++++++------- 4 files changed, 62 insertions(+), 34 deletions(-) diff --git a/models/artemis_wrapped/dim_artemis_wrapped.sql b/models/artemis_wrapped/dim_artemis_wrapped.sql index d962c75c..50c8380b 100644 --- a/models/artemis_wrapped/dim_artemis_wrapped.sql +++ b/models/artemis_wrapped/dim_artemis_wrapped.sql @@ -33,13 +33,13 @@ categories as ( , ARRAY_TO_STRING(boomer.reason, ', ') ) as reason from {{ref('dim_blockbuster')}} block_buster - full outer join {{ref('dim_bob_the_builder')}} bob_the_builder using (address) - full outer join {{ref('dim_botimus_prime')}} botimus_prime using (address) - full outer join {{ref('dim_terminally_based')}} terminally_based using (address) - full outer join {{ref('dim_wolf_of_wallstreet')}} wolf_of_wallstreet using (address) - full outer join {{ref('dim_dora_the_explorer')}} dora_the_explorer using (address) - full outer join {{ref('dim_old_mcdonald')}} old_mcdonald using (address) - full outer join {{ref('dim_boomer')}} boomer using (address) + full outer join {{ref('dim_bob_the_builder')}} bob_the_builder on lower(block_buster.address) = lower(bob_the_builder.address) + full outer join {{ref('dim_botimus_prime')}} botimus_prime on lower(block_buster.address) = lower(botimus_prime.address) + full outer join {{ref('dim_terminally_based')}} terminally_based on lower(block_buster.address) = lower(terminally_based.address) + full outer join {{ref('dim_wolf_of_wallstreet')}} wolf_of_wallstreet on lower(block_buster.address) = lower(wolf_of_wallstreet.address) + full outer join {{ref('dim_dora_the_explorer')}} dora_the_explorer on lower(block_buster.address) = lower(dora_the_explorer.address) + full outer join {{ref('dim_old_mcdonald')}} old_mcdonald on lower(block_buster.address) = lower(old_mcdonald.address) + full outer join {{ref('dim_boomer')}} boomer on lower(block_buster.address) = lower(boomer.address) ) select @@ -54,5 +54,5 @@ select , days_onchain_percent_rank as days_onchain_percent_rank , apps_used , apps_used_percent_rank as apps_used_percent_rank -from {{ref('agg_artemis_wrapped_metrics')}} -left join categories using (address) \ No newline at end of file +from {{ref('agg_artemis_wrapped_metrics')}} wrapped +left join categories on lower(wrapped.address) = lower(categories.address) \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql b/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql index 55d64aa2..d3fe0382 100644 --- a/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql +++ b/models/artemis_wrapped/metrics/agg_artemis_wrapped_metrics.sql @@ -10,4 +10,16 @@ select , days_onchain_percent_rank , apps_used , apps_used_percent_rank -from {{ ref('agg_base_artemis_wrapped_metrics') }} \ No newline at end of file +from {{ ref('agg_base_artemis_wrapped_metrics_with_percent') }} +union all +select + address + , total_txns + , total_txns_percent_rank + , total_gas_paid + , total_gas_paid_percent_rank + , days_onchain + , days_onchain_percent_rank + , apps_used + , apps_used_percent_rank +from {{ ref('agg_solana_artemis_wrapped_metrics_with_percent') }} \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql b/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql index 3c23b6fd..e8435c2d 100644 --- a/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql +++ b/models/artemis_wrapped/metrics/agg_base_artemis_wrapped_metrics_with_percent.sql @@ -3,19 +3,27 @@ SELECT address, total_txns, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.total_txns > outer_data.total_txns) AS total_txns_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 97059729.0 + FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.total_txns > outer_data.total_txns + ) AS total_txns_percent_rank, total_gas_paid, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.total_gas_paid > outer_data.total_gas_paid) AS total_gas_paid_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 97059729.0 + FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.total_gas_paid > outer_data.total_gas_paid + ) AS total_gas_paid_percent_rank, days_onchain, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.days_onchain > outer_data.days_onchain) AS days_onchain_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 97059729.0 + FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.days_onchain > outer_data.days_onchain + ) AS days_onchain_percent_rank, apps_used, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.apps_used > outer_data.apps_used) AS apps_used_percent_rank + ( + SELECT COUNT(*) * 1.0 / 97059729.0 + FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.apps_used > outer_data.apps_used + ) AS apps_used_percent_rank FROM {{ref('agg_base_artemis_wrapped_metrics')}} AS outer_data \ No newline at end of file diff --git a/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql b/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql index cb1b10bf..4d2079f5 100644 --- a/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql +++ b/models/artemis_wrapped/metrics/agg_solana_artemis_wrapped_metrics_with_percent.sql @@ -2,19 +2,27 @@ SELECT address, total_txns, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.total_txns > outer_data.total_txns) AS total_txns_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 660782282.0 + FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.total_txns > outer_data.total_txns + ) AS total_txns_percent_rank, total_gas_paid, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.total_gas_paid > outer_data.total_gas_paid) AS total_gas_paid_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 660782282.0 + FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.total_gas_paid > outer_data.total_gas_paid + ) AS total_gas_paid_percent_rank, days_onchain, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.days_onchain > outer_data.days_onchain) AS days_onchain_percent_rank, + ( + SELECT COUNT(*) * 1.0 / 660782282.0 + FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.days_onchain > outer_data.days_onchain + ) AS days_onchain_percent_rank, apps_used, - (SELECT COUNT(*) * 1.0 / (SELECT COUNT(*) FROM agg_data) - FROM agg_data AS inner_data - WHERE inner_data.apps_used > outer_data.apps_used) AS apps_used_percent_rank + ( + SELECT COUNT(*) * 1.0 / 660782282.0 + FROM {{ref('agg_solana_artemis_wrapped_metrics')}} AS inner_data + WHERE inner_data.apps_used > outer_data.apps_used + ) AS apps_used_percent_rank FROM {{ref("agg_solana_artemis_wrapped_metrics")}} AS outer_data