Skip to content

Commit

Permalink
Merge pull request #21 from Artemis-xyz/sm-911-cosmos-models
Browse files Browse the repository at this point in the history
Customer 911: Updating cosmos models
  • Loading branch information
SebMelendez01 authored Apr 17, 2024
2 parents 575c07e + ce35c78 commit c69ec70
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions models/staging/cosmoshub/fact_cosmoshub_daa.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ with
)
select
date(value:date) as date,
value:"DAU"::int as daa,
value as source,
value:"daa"::int as daa,
'cosmoshub' as chain
from
{{ source("PROD_LANDING", "raw_cosmoshub_daa") }},
lateral flatten(input => parse_json(source_json))
where extraction_date = (select max_date from max_extraction)
where extraction_date = (select max_date from max_extraction) and date(value:date) is not null
2 changes: 1 addition & 1 deletion models/staging/cosmoshub/fact_cosmoshub_daa_gold.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{ config(materialized="table") }}
select date, daa, chain, source
select date, daa, chain
from {{ ref("fact_cosmoshub_daa") }}
9 changes: 5 additions & 4 deletions models/staging/cosmoshub/fact_cosmoshub_fees_and_revenue.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ with
),
cosmoshub_prices as ({{ get_coingecko_price_with_latest("cosmos") }}),
raw as (
select date(value:date) as date, value:"fees"::int as fees, value as source
select date(value:date) as date, value:"fee"::float as fees, value:"fee_currency"::string as fee_currency
from
{{ source("PROD_LANDING", "raw_cosmoshub_fees") }},
lateral flatten(input => parse_json(source_json))
Expand All @@ -15,8 +15,9 @@ with
select
raw.date,
'cosmoshub' as chain,
fees as gas,
fees * coalesce(price, 0) as gas_usd,
sum(fees) as gas,
sum(fees * coalesce(price, 0)) as gas_usd,
gas_usd * .02 as revenue
from raw
left join cosmoshub_prices on raw.date = cosmoshub_prices.date
left join cosmoshub_prices on raw.date = cosmoshub_prices.date and fee_currency = 'uatom'
group by 1
3 changes: 1 addition & 2 deletions models/staging/cosmoshub/fact_cosmoshub_txns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ with
select
date(value:date) as date,
value:txns::int as txns,
value as source,
'cosmoshub' as chain
from
{{ source("PROD_LANDING", "raw_cosmoshub_txns") }},
lateral flatten(input => parse_json(source_json))
where extraction_date = (select max_date from max_extraction)
where extraction_date = (select max_date from max_extraction) and date(value:date) is not null
2 changes: 1 addition & 1 deletion models/staging/cosmoshub/fact_cosmoshub_txns_gold.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{ config(materialized="table") }}
select date, txns, chain, source
select date, txns, chain
from {{ ref("fact_cosmoshub_txns") }}

0 comments on commit c69ec70

Please sign in to comment.