Skip to content

Commit

Permalink
Alw akash dates fix (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwes authored Jul 12, 2024
1 parent ddd7ece commit f3fbda7
Showing 1 changed file with 70 additions and 52 deletions.
122 changes: 70 additions & 52 deletions models/projects/akash/core/ez_akash_metrics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,73 @@
)
}}

with
active_providers as (select * from {{ ref("fact_akash_active_providers_silver") }}),
active_leases as (select * from {{ ref("fact_akash_active_leases_silver") }}),
new_leases as (select * from {{ ref("fact_akash_new_leases_silver") }}),
compute_fees_native as (
select * from {{ ref("fact_akash_compute_fees_native_silver") }}
),
compute_fees_usdc as (
select * from {{ ref("fact_akash_compute_fees_usdc_silver") }}
),
compute_fees_total_usd as (
select * from {{ ref("fact_akash_compute_fees_total_usd_silver") }}
),
validator_fees_native as (
select * from {{ ref("fact_akash_validator_fees_native_silver") }}
),
validator_fees as (select * from {{ ref("fact_akash_validator_fees_silver") }}),
total_fees as (select * from {{ ref("fact_akash_total_fees_silver") }}),
revenue as (select * from {{ ref("fact_akash_revenue_silver") }}),
burns as (select * from {{ ref("fact_akash_burns_native_silver") }}),
mints as (select * from {{ ref("fact_akash_mints_silver") }})

select
active_leases.date,
'akash' as chain,
coalesce(active_leases.active_leases, 0) as active_leases,
coalesce(active_providers.active_providers, 0) as active_providers,
coalesce(new_leases.new_leases, 0) as new_leases,
(coalesce(compute_fees_native.compute_fees_native, 0)) / 1e6 as compute_fees_native,
(coalesce(compute_fees_usdc.compute_fees_usdc, 0)) / 1e6 as compute_fees_usdc,
(coalesce(compute_fees_total_usd.compute_fees_total_usd, 0))
/ 1e6 as compute_fees_total_usd,
coalesce(validator_fees_native.validator_fees_native, 0) as validator_fees_native,
coalesce(validator_fees.validator_fees, 0) as validator_fees,
coalesce(total_fees.total_fees, 0) as total_fees,
coalesce(revenue.revenue, 0) as revenue,
coalesce(burns.total_burned_native, 0) as total_burned_native,
coalesce(mints.mints, 0) as mints
from active_leases
full join active_providers on active_leases.date = active_providers.date
full join new_leases on active_leases.date = new_leases.date
full join compute_fees_native on active_leases.date = compute_fees_native.date
full join compute_fees_usdc on active_leases.date = compute_fees_usdc.date
full join compute_fees_total_usd on active_leases.date = compute_fees_total_usd.date
full join validator_fees_native on active_leases.date = validator_fees_native.date
full join validator_fees on active_leases.date = validator_fees.date
full join total_fees on active_leases.date = total_fees.date
full join revenue on active_leases.date = revenue.date
full join burns on active_leases.date = burns.date
full join mints on active_leases.date = mints.date
where active_leases.date < to_date(sysdate())
order by date desc
WITH
active_providers AS (
SELECT * FROM {{ ref("fact_akash_active_providers_silver") }}
)

, active_leases AS (SELECT * FROM {{ ref("fact_akash_active_leases_silver") }})

, new_leases AS (SELECT * FROM {{ ref("fact_akash_new_leases_silver") }})

, compute_fees_native AS (
SELECT * FROM {{ ref("fact_akash_compute_fees_native_silver") }}
)

, compute_fees_usdc AS (
SELECT * FROM {{ ref("fact_akash_compute_fees_usdc_silver") }}
)

, compute_fees_total_usd AS (
SELECT * FROM {{ ref("fact_akash_compute_fees_total_usd_silver") }}
)

, validator_fees_native AS (
SELECT * FROM {{ ref("fact_akash_validator_fees_native_silver") }}
)

, validator_fees AS (SELECT * FROM {{ ref("fact_akash_validator_fees_silver") }}
)

, total_fees AS (SELECT * FROM {{ ref("fact_akash_total_fees_silver") }})

, revenue AS (SELECT * FROM {{ ref("fact_akash_revenue_silver") }})

, mints AS (SELECT * FROM {{ ref("fact_akash_mints_silver") }})

, burns AS (SELECT * FROM {{ ref("fact_akash_burns_native_silver") }})


SELECT
mints.date
, 'akash' AS chain
, coalesce(active_leases.active_leases, 0) AS active_leases
, coalesce(active_providers.active_providers, 0) AS active_providers
, coalesce(new_leases.new_leases, 0) AS new_leases
, (coalesce(compute_fees_native.compute_fees_native, 0))
/ 1e6 AS compute_fees_native
, (coalesce(compute_fees_usdc.compute_fees_usdc, 0))
/ 1e6 AS compute_fees_usdc
, (coalesce(compute_fees_total_usd.compute_fees_total_usd, 0))
/ 1e6 AS compute_fees_total_usd
, coalesce(validator_fees_native.validator_fees_native, 0)
AS validator_fees_native
, coalesce(validator_fees.validator_fees, 0) AS validator_fees
, coalesce(total_fees.total_fees, 0) AS total_fees
, coalesce(revenue.revenue, 0) AS revenue
, coalesce(burns.total_burned_native, 0) AS total_burned_native
, coalesce(mints.mints, 0) AS mints
FROM mints
LEFT JOIN active_providers ON mints.date = active_providers.date
LEFT JOIN new_leases ON mints.date = new_leases.date
LEFT JOIN compute_fees_native ON mints.date = compute_fees_native.date
LEFT JOIN compute_fees_usdc ON mints.date = compute_fees_usdc.date
LEFT JOIN compute_fees_total_usd ON mints.date = compute_fees_total_usd.date
LEFT JOIN validator_fees_native ON mints.date = validator_fees_native.date
LEFT JOIN validator_fees ON mints.date = validator_fees.date
LEFT JOIN total_fees ON mints.date = total_fees.date
LEFT JOIN revenue ON mints.date = revenue.date
LEFT JOIN burns ON mints.date = burns.date
LEFT JOIN active_leases ON mints.date = active_leases.date
WHERE mints.date < to_date(sysdate())
ORDER BY date DESC

0 comments on commit f3fbda7

Please sign in to comment.