Skip to content

Commit

Permalink
Merge branch 'duneanalytics:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Ndifreke000 authored Oct 25, 2024
2 parents 66065eb + 3a7b3f2 commit 456f626
Show file tree
Hide file tree
Showing 1,002 changed files with 7,240 additions and 5,584 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/dbt_run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
- name: dbt seed
run: "dbt seed $PROFILE --select @state:modified --exclude tag:prod_exclude tag:remove --state . --project-dir ${PROJECT_DIR}"

- name: list downstream models
run: "./scripts/list_modified_downstream.sh"

- name: dbt run initial model(s)
run: "dbt -x run $PROFILE --select state:modified --exclude tag:prod_exclude tag:remove --defer --state . --project-dir ${PROJECT_DIR}"

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ models:
- name: mock_table
columns:
- name: tx_id
tests:
data_tests:
- unique
- not_null
```
Expand Down
4 changes: 2 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "pypi"
numpy = "2.0.12"
pre-commit = "2.20.0"
pytest = "7.1.3"
dbt-trino = "1.7.0"
dbt-trino = "1.8.2"

[requires]
python_version = "3.9"
python_version = "3.9"
1,397 changes: 738 additions & 659 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ models:
columns:
- name: tx_hash
description: "Table primary key: a transaction hash (tx_hash) is a unique identifier for a transaction."
tests:
data_tests:
- unique
- not_null

Expand Down
3 changes: 2 additions & 1 deletion dbt_subprojects/daily_spellbook/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
name: "daily_spellbook"
version: "1.0.0"
config-version: 2
require-dbt-version: ">=1.8.0"

quoting:
database: false
Expand Down Expand Up @@ -33,7 +34,7 @@ clean-targets: # directories to be removed by `dbt clean`

# Configuring tests
# Full documentation: https://docs.getdbt.com/reference/test-configs
tests:
data_tests:
daily_spellbook:
+store_failures: true # store failures for all tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ models:
config:
tags: ['metrics', 'dune', 'index', 'daily']
description: "Combine transactions, transfers and fees index values to get a daily dune index value"
tests:
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ with source as (
select
c.blockchain
, c.last_1_days_dune_index as last_1_days_dune_index_contribution
, (c.last_1_days_dune_index / t.total_cross_chain_last_1_days_dune_index) * 100 as last_1_days_dune_index_contribution_percent
, c.last_1_days_dune_index / t.total_cross_chain_last_1_days_dune_index as last_1_days_dune_index_contribution_percent
, t.total_cross_chain_last_1_days_dune_index
, p.previous_1_days_dune_index as previous_1_days_dune_index_contribution
, ((c.last_1_days_dune_index - coalesce(p.previous_1_days_dune_index, 0)) / coalesce(p.previous_1_days_dune_index, 1)) * 100 AS daily_percent_change
, (c.last_1_days_dune_index - coalesce(p.previous_1_days_dune_index, 0)) / coalesce(p.previous_1_days_dune_index, 1) AS daily_percent_change
from
current_day as c
left join previous_day as p
Expand Down Expand Up @@ -83,10 +83,10 @@ with source as (
select
c.blockchain
, c.last_7_days_dune_index as last_7_days_dune_index_contribution
, (c.last_7_days_dune_index / t.total_cross_chain_last_7_days_dune_index) * 100 as last_7_days_dune_index_contribution_percent
, c.last_7_days_dune_index / t.total_cross_chain_last_7_days_dune_index as last_7_days_dune_index_contribution_percent
, t.total_cross_chain_last_7_days_dune_index
, p.previous_7_days_dune_index as previous_7_days_dune_index_contribution
, ((c.last_7_days_dune_index - coalesce(p.previous_7_days_dune_index, 0)) / coalesce(p.previous_7_days_dune_index, 1)) * 100 AS weekly_percent_change
, (c.last_7_days_dune_index - coalesce(p.previous_7_days_dune_index, 0)) / coalesce(p.previous_7_days_dune_index, 1) AS weekly_percent_change
from
current_week as c
left join previous_week as p
Expand Down Expand Up @@ -124,10 +124,10 @@ with source as (
select
c.blockchain
, c.last_30_days_dune_index as last_30_days_dune_index_contribution
, (c.last_30_days_dune_index / t.total_cross_chain_last_30_days_dune_index) * 100 as last_30_days_dune_index_contribution_percent
, c.last_30_days_dune_index / t.total_cross_chain_last_30_days_dune_index as last_30_days_dune_index_contribution_percent
, t.total_cross_chain_last_30_days_dune_index
, p.previous_30_days_dune_index as previous_30_days_dune_index_contribution
, ((c.last_30_days_dune_index - coalesce(p.previous_30_days_dune_index, 0)) / coalesce(p.previous_30_days_dune_index, 1)) * 100 AS monthly_percent_change
, (c.last_30_days_dune_index - coalesce(p.previous_30_days_dune_index, 0)) / coalesce(p.previous_30_days_dune_index, 1) AS monthly_percent_change
from
current_month as c
left join previous_month as p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ models:
config:
tags: ['metrics', 'fees', 'gas', 'daily']
description: "Sum of total fees spent per day across all chains available in raw gas.fees table"
tests:
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
Expand All @@ -27,7 +27,7 @@ models:
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"
tests:
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)
}}

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

with baseline as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ with source as (
c.blockchain
, c.last_1_days_gas_fees_usd
, p.previous_1_days_gas_fees_usd
, ((c.last_1_days_gas_fees_usd - coalesce(p.previous_1_days_gas_fees_usd, 0)) / coalesce(p.previous_1_days_gas_fees_usd, 1)) * 100 AS daily_percent_change
, (c.last_1_days_gas_fees_usd - coalesce(p.previous_1_days_gas_fees_usd, 0)) / coalesce(p.previous_1_days_gas_fees_usd, 1) AS daily_percent_change
, t.total_cross_chain_last_1_days_gas_fees_usd
, (c.last_1_days_gas_fees_usd / t.total_cross_chain_last_1_days_gas_fees_usd) * 100 AS percent_total_last_1_days_fees_usd
, c.last_1_days_gas_fees_usd / t.total_cross_chain_last_1_days_gas_fees_usd AS percent_total_last_1_days_fees_usd
from
current_day as c
left join previous_day as p
Expand Down Expand Up @@ -81,9 +81,9 @@ with source as (
c.blockchain
, c.last_7_days_gas_fees_usd
, p.previous_7_days_gas_fees_usd
, ((c.last_7_days_gas_fees_usd - coalesce(p.previous_7_days_gas_fees_usd, 0)) / coalesce(p.previous_7_days_gas_fees_usd, 1)) * 100 AS weekly_percent_change
, (c.last_7_days_gas_fees_usd - coalesce(p.previous_7_days_gas_fees_usd, 0)) / coalesce(p.previous_7_days_gas_fees_usd, 1) AS weekly_percent_change
, t.total_cross_chain_last_7_days_gas_fees_usd
, (c.last_7_days_gas_fees_usd / t.total_cross_chain_last_7_days_gas_fees_usd) * 100 AS percent_total_last_7_days_gas_fees_usd
, c.last_7_days_gas_fees_usd / t.total_cross_chain_last_7_days_gas_fees_usd AS percent_total_last_7_days_gas_fees_usd
from
current_week as c
left join previous_week as p
Expand Down Expand Up @@ -122,9 +122,9 @@ with source as (
c.blockchain
, c.last_30_days_gas_fees_usd
, p.previous_30_days_gas_fees_usd
, ((c.last_30_days_gas_fees_usd - coalesce(p.previous_30_days_gas_fees_usd, 0)) / coalesce(p.previous_30_days_gas_fees_usd, 1)) * 100 AS monthly_percent_change
, (c.last_30_days_gas_fees_usd - coalesce(p.previous_30_days_gas_fees_usd, 0)) / coalesce(p.previous_30_days_gas_fees_usd, 1) AS monthly_percent_change
, t.total_cross_chain_last_30_days_gas_fees_usd
, (c.last_30_days_gas_fees_usd / t.total_cross_chain_last_30_days_gas_fees_usd) * 100 AS percent_total_last_30_days_gas_fees_usd
, c.last_30_days_gas_fees_usd / t.total_cross_chain_last_30_days_gas_fees_usd AS percent_total_last_30_days_gas_fees_usd
from
current_month as c
left join previous_month as p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ models:
config:
tags: ['metrics', 'transactions', 'daily']
description: "Sum of total tx's per day across all chains"
tests:
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
Expand All @@ -27,7 +27,7 @@ models:
config:
tags: ['metrics', 'transactions', 'index', 'daily']
description: "Each day, per chain, compare the adoption of total transactions relative to the baseline expectation"
tests:
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ with raw_tx as (
{{ ref('metrics_net_transfers') }}
where
1 = 1
and net_transfer_amount_usd >= 1 --only include tx's where transfer value is greater at least $1
and net_transfer_amount_usd >= 1 --only include tx's where transfer value is at least $1
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)
}}

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

with baseline as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ with source as (
c.blockchain
, c.last_1_days_tx_count
, p.previous_1_days_tx_count
, ((cast(c.last_1_days_tx_count as double) - coalesce(cast(p.previous_1_days_tx_count as double), 0)) / coalesce(cast(p.previous_1_days_tx_count as double), 1)) * 100 AS daily_percent_change
, (cast(c.last_1_days_tx_count as double) - coalesce(cast(p.previous_1_days_tx_count as double), 0)) / coalesce(cast(p.previous_1_days_tx_count as double), 1) AS daily_percent_change
, t.total_cross_chain_last_1_days_tx_count
, (cast(c.last_1_days_tx_count as double) / cast(t.total_cross_chain_last_1_days_tx_count as double)) * 100 AS percent_total_last_1_days_tx_count
, cast(c.last_1_days_tx_count as double) / cast(t.total_cross_chain_last_1_days_tx_count as double) AS percent_total_last_1_days_tx_count
from
current_day as c
left join previous_day as p
Expand Down Expand Up @@ -81,9 +81,9 @@ with source as (
c.blockchain
, c.last_7_days_tx_count
, p.previous_7_days_tx_count
, ((cast(c.last_7_days_tx_count as double) - coalesce(cast(p.previous_7_days_tx_count as double), 0)) / coalesce(cast(p.previous_7_days_tx_count as double), 1)) * 100 AS weekly_percent_change
, (cast(c.last_7_days_tx_count as double) - coalesce(cast(p.previous_7_days_tx_count as double), 0)) / coalesce(cast(p.previous_7_days_tx_count as double), 1) AS weekly_percent_change
, t.total_cross_chain_last_7_days_tx_count
, (cast(c.last_7_days_tx_count as double) / cast(t.total_cross_chain_last_7_days_tx_count as double)) * 100 AS percent_total_last_7_days_tx_count
, cast(c.last_7_days_tx_count as double) / cast(t.total_cross_chain_last_7_days_tx_count as double) AS percent_total_last_7_days_tx_count
from
current_week as c
left join previous_week as p
Expand Down Expand Up @@ -122,9 +122,9 @@ with source as (
c.blockchain
, c.last_30_days_tx_count
, p.previous_30_days_tx_count
, ((cast(c.last_30_days_tx_count as double) - coalesce(cast(p.previous_30_days_tx_count as double), 0)) / coalesce(cast(p.previous_30_days_tx_count as double), 1)) * 100 AS monthly_percent_change
, (cast(c.last_30_days_tx_count as double) - coalesce(cast(p.previous_30_days_tx_count as double), 0)) / coalesce(cast(p.previous_30_days_tx_count as double), 1) AS monthly_percent_change
, t.total_cross_chain_last_30_days_tx_count
, (cast(c.last_30_days_tx_count as double) / cast(t.total_cross_chain_last_30_days_tx_count as double)) * 100 AS percent_total_last_30_days_tx_count
, cast(c.last_30_days_tx_count as double) / cast(t.total_cross_chain_last_30_days_tx_count as double) AS percent_total_last_30_days_tx_count
from
current_month as c
left join previous_month as p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ models:
with the positive net received (aka received) it adds up to 0 since the net sent should equal the net received.
For example, if I give you $1 that's -1 sent (from me) and +1 received (by you) which adds to 0.
This query counts the received to show that $1 was effectively transfered."
tests:
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
Expand All @@ -32,7 +32,7 @@ models:
tags: ['metrics', 'transfers', 'daily']
description: |
"Sum of total transfer amount per day across all chain."
tests:
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
Expand All @@ -51,7 +51,7 @@ models:
config:
tags: ['metrics', 'transfers', 'index', 'daily']
description: "Each day, per chain, compare the adoption of total transfers relative to the baseline expectation"
tests:
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ select
, sum(net_transfer_amount_usd) as net_transfer_amount_usd
from
net_transfers
where
net_transfer_amount_usd > 0
group by
blockchain
, block_date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ from
{{ ref('metrics_net_transfers') }}
where
1 = 1
and net_transfer_amount_usd > 0
{% if is_incremental() %}
and {{ incremental_predicate('block_date') }}
{% endif %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
)
}}

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

with baseline as (
select
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ with source as (
c.blockchain
, c.last_1_days_net_transfer_amount_usd
, p.previous_1_days_net_transfer_amount_usd
, ((cast(c.last_1_days_net_transfer_amount_usd as double) - coalesce(cast(p.previous_1_days_net_transfer_amount_usd as double), 0)) / coalesce(cast(p.previous_1_days_net_transfer_amount_usd as double), 1)) * 100 AS daily_percent_change
, (cast(c.last_1_days_net_transfer_amount_usd as double) - coalesce(cast(p.previous_1_days_net_transfer_amount_usd as double), 0)) / coalesce(cast(p.previous_1_days_net_transfer_amount_usd as double), 1) AS daily_percent_change
, t.total_cross_chain_last_1_days_net_transfer_amount_usd
, (cast(c.last_1_days_net_transfer_amount_usd as double) / cast(t.total_cross_chain_last_1_days_net_transfer_amount_usd as double)) * 100 AS percent_total_last_1_days_net_transfer_amount_usd
, cast(c.last_1_days_net_transfer_amount_usd as double) / cast(t.total_cross_chain_last_1_days_net_transfer_amount_usd as double) AS percent_total_last_1_days_net_transfer_amount_usd
from
current_day as c
left join previous_day as p
Expand Down Expand Up @@ -81,9 +81,9 @@ with source as (
c.blockchain
, c.last_7_days_net_transfer_amount_usd
, p.previous_7_days_net_transfer_amount_usd
, ((cast(c.last_7_days_net_transfer_amount_usd as double) - coalesce(cast(p.previous_7_days_net_transfer_amount_usd as double), 0)) / coalesce(cast(p.previous_7_days_net_transfer_amount_usd as double), 1)) * 100 AS weekly_percent_change
, (cast(c.last_7_days_net_transfer_amount_usd as double) - coalesce(cast(p.previous_7_days_net_transfer_amount_usd as double), 0)) / coalesce(cast(p.previous_7_days_net_transfer_amount_usd as double), 1) AS weekly_percent_change
, t.total_cross_chain_last_7_days_net_transfer_amount_usd
, (cast(c.last_7_days_net_transfer_amount_usd as double) / cast(t.total_cross_chain_last_7_days_net_transfer_amount_usd as double)) * 100 AS percent_total_last_7_days_net_transfer_amount_usd
, cast(c.last_7_days_net_transfer_amount_usd as double) / cast(t.total_cross_chain_last_7_days_net_transfer_amount_usd as double) AS percent_total_last_7_days_net_transfer_amount_usd
from
current_week as c
left join previous_week as p
Expand Down Expand Up @@ -122,9 +122,9 @@ with source as (
c.blockchain
, c.last_30_days_net_transfer_amount_usd
, p.previous_30_days_net_transfer_amount_usd
, ((cast(c.last_30_days_net_transfer_amount_usd as double) - coalesce(cast(p.previous_30_days_net_transfer_amount_usd as double), 0)) / coalesce(cast(p.previous_30_days_net_transfer_amount_usd as double), 1)) * 100 AS monthly_percent_change
, (cast(c.last_30_days_net_transfer_amount_usd as double) - coalesce(cast(p.previous_30_days_net_transfer_amount_usd as double), 0)) / coalesce(cast(p.previous_30_days_net_transfer_amount_usd as double), 1) AS monthly_percent_change
, t.total_cross_chain_last_30_days_net_transfer_amount_usd
, (cast(c.last_30_days_net_transfer_amount_usd as double) / cast(t.total_cross_chain_last_30_days_net_transfer_amount_usd as double)) * 100 AS percent_total_last_30_days_net_transfer_amount_usd
, cast(c.last_30_days_net_transfer_amount_usd as double) / cast(t.total_cross_chain_last_30_days_net_transfer_amount_usd as double) AS percent_total_last_30_days_net_transfer_amount_usd
from
current_month as c
left join previous_month as p
Expand Down
Loading

0 comments on commit 456f626

Please sign in to comment.