Skip to content

Commit

Permalink
Blur: inital fundamentals commit (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwes authored Sep 5, 2024
1 parent ababc49 commit fd298e2
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions databases.csv
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BITCOIN
BITCOIN_FLIPSIDE
BLAST
BLAST_FLIPSIDE
BLUR
BSC
BSC_FLIPSIDE
BUSD
Expand Down
2 changes: 2 additions & 0 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ models:
+snowflake_warehouse: "BITCOIN"
blast:
+snowflake_warehouse: "BLAST"
blur:
+snowflake_warehouse: "BLUR"
cardano:
+snowflake_warehouse: "CARDANO"
cctp:
Expand Down
34 changes: 34 additions & 0 deletions models/projects/blur/core/ez_blur_metrics.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{
config(
materialized = 'table',
snowflake_warehouse = 'BLUR',
database = 'blur',
schema = 'core',
alias = 'ez_metrics'
)
}}

with
blur_fees as (
select *
from {{ ref("fact_blur_fees") }}
)
, blur_daus as (
select *
from {{ ref("fact_blur_daus") }}
)
, blur_daily_txns as (
select *
from {{ ref("fact_blur_daily_txns") }}
)

select
blur_daus.date,
blur_daus.dau,
blur_daily_txns.daily_txns as txns,
blur_fees.fees
from blur_daus
left join blur_daily_txns
on blur_daus.date = blur_daily_txns.date
left join blur_fees
on blur_daus.date = blur_fees.date
8 changes: 8 additions & 0 deletions models/staging/blur/__blur__sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
sources:
- name: PROD_LANDING
schema: PROD_LANDING
database: LANDING_DATABASE
tables:
- name: raw_blur_dau
- name: raw_blur_fees
- name: raw_blur_daily_txns
26 changes: 26 additions & 0 deletions models/staging/blur/fact_blur_daily_txns.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{
config(
materialized = 'table'
)
}}

with
max_extraction as (
select max(extraction_date) as max_date
from {{ source("PROD_LANDING", "raw_blur_daily_txns") }}
),
latest_data as (
select parse_json(source_json) as data
from {{ source("PROD_LANDING", "raw_blur_daily_txns") }}
where extraction_date = (select max_date from max_extraction)
),
flattened_data as (
select
date(to_timestamp(SUBSTR(f.value:time, 0, 10)::date)) as date,
f.value:trades::number as daily_txns
from latest_data, lateral flatten(input => data) as f
)
select date, daily_txns, 'ethereum' as chain, 'blur' as app
from flattened_data
where date < to_date(sysdate())
order by date desc
26 changes: 26 additions & 0 deletions models/staging/blur/fact_blur_daus.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{
config(
materialized = 'table'
)
}}

with
max_extraction as (
select max(extraction_date) as max_date
from {{ source("PROD_LANDING", "raw_blur_dau") }}
),
latest_data as (
select parse_json(source_json) as data
from {{ source("PROD_LANDING", "raw_blur_dau") }}
where extraction_date = (select max_date from max_extraction)
),
flattened_data as (
select
date(to_timestamp(SUBSTR(f.value:time, 0, 10)::date)) as date,
f.value:traders::number as dau
from latest_data, lateral flatten(input => data) as f
)
select date, dau, 'ethereum' as chain, 'blur' as app
from flattened_data
where date < to_date(sysdate())
order by date desc
26 changes: 26 additions & 0 deletions models/staging/blur/fact_blur_fees.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{
config(
materialized = 'table'
)
}}

with
max_extraction as (
select max(extraction_date) as max_date
from {{ source("PROD_LANDING", "raw_blur_fees") }}
),
latest_data as (
select parse_json(source_json) as data
from {{ source("PROD_LANDING", "raw_blur_fees") }}
where extraction_date = (select max_date from max_extraction)
),
flattened_data as (
select
date(to_timestamp(SUBSTR(f.value:time, 0, 10)::date)) as date,
f.value:fees_paid::number as fees
from latest_data, lateral flatten(input => data) as f
)
select date, fees, 'ethereum' as chain, 'blur' as app
from flattened_data
where date < to_date(sysdate())
order by date desc

0 comments on commit fd298e2

Please sign in to comment.