Skip to content

Commit

Permalink
clean up index and stats models
Browse files Browse the repository at this point in the history
  • Loading branch information
0xRobin committed Nov 22, 2024
1 parent 1a7d3d0 commit b6b2ade
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 825 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ models:
- name: metrics_dune_index_daily
meta:
sector: metrics
contributors: jeff-dude
contributors: jeff-dude, 0xRob
config:
tags: ['metrics', 'dune', 'index', 'daily']
description: "Combine transactions, transfers and fees index values to get a daily dune index value"
Expand All @@ -13,10 +13,3 @@ models:
combination_of_columns:
- blockchain
- block_date
- name: metrics_dune_index_stats
meta:
sector: metrics
contributors: jeff-dude
config:
tags: ['metrics', 'dune', 'index', 'daily']
description: "View containing various time aggregations of the dune index"
Original file line number Diff line number Diff line change
@@ -1,21 +1,71 @@
{{ config(
schema = 'metrics'
, alias = 'dune_index_daily'
, materialized = 'view'
, materialized = 'incremental'
, file_format = 'delta'
, incremental_strategy = 'merge'
, unique_key = ['blockchain', 'block_date']
, incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')]
)
}}

{% set baseline_date = '2018-01-01' %}
{% set start_date = '2015-08-21' %}

with
fees as (
select
blockchain
, block_date
, gas_fees_usd
, (gas_fees_usd / (select sum(gas_fees_usd) from {{ ref('metrics_gas_fees_daily') }} where block_date = date '{{ baseline_date }}')) * 10 as fees_index
from
{{ ref('metrics_gas_fees_daily') }}
where
block_date >= date '{{ start_date }}'
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
),
transactions as (
select
blockchain
, block_date
, tx_count
, (tx_count / cast(select sum(tx_count) from {{ ref('metrics_transactions_daily') }} where block_date = date '{{ baseline_date }}' as double)) * 10 as tx_index
from
{{ ref('metrics_transactions_daily') }}
where
block_date >= date '{{ start_date }}'
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
)
,transfers as (
select
blockchain
, block_date
, net_transfer_amount_usd
, (net_transfer_amount_usd / cast(select sum(net_transfer_amount_usd) from {{ ref('metrics_transfers_daily') }} where block_date = date '{{ baseline_date }}' as double)) * 10 as transfers_index
from
{{ ref('metrics_transfers_daily') }}
where
block_date >= date '{{ start_date }}'
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
)

select
blockchain
, block_date
, coalesce(f.fees_index,0) as fees_index
, coalesce(tr.transfers_index,0) as transfers_index
, coalesce(tx.tx_index,0) as tx_index
, coalesce(f.fees_index,0)*0.45 + coalesce(tr.transfers_index,0)*0.45 + coalesce(tx.tx_index,0)*0.10 as dune_index
from {{ ref('metrics_fees_index_daily') }} as f
left join
{{ ref('metrics_transfers_index_daily') }} as tr
using (blockchain, block_date)
left join
{{ ref('metrics_transactions_index_daily') }} as tx
using (blockchain, block_date)
, 0.45 * coalesce(fees_index,0) + 0.45 * coalesce(transfers_index,0) + 0.10 * coalesce(tx_index,0) as dune_index
, coalesce(fees_index,0) as fees_index
, coalesce(transfers_index,0) as transfers_index
, coalesce(tx_index,0) as tx_index
, gas_fees_usd
, tx_count
, net_transfer_amount_usd
from fees
left join transfers using (blockchain, block_date)
left join transactions using (blockchain, block_date)

This file was deleted.

19 changes: 0 additions & 19 deletions dbt_subprojects/daily_spellbook/models/_metrics/fees/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,3 @@ models:
combination_of_columns:
- blockchain
- block_date
- name: metrics_gas_fees_stats
meta:
sector: metrics
contributors: jeff-dude
config:
tags: ['metrics', 'fees', 'gas']
description: "View of gas fees per blockchain aggregated to various levels. The goal is to output one row per chain with stats availble for use in counter visuals."
- name: metrics_fees_index_daily
meta:
sector: metrics
contributors: jeff-dude
config:
tags: ['metrics', 'fees', 'gas', 'index', 'daily']
description: "Each day, per chain, compare the adoption of activity based on total gas fees relative to the baseline expectation"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
- block_date

This file was deleted.

Loading

0 comments on commit b6b2ade

Please sign in to comment.