From 9e15f71209051cedeefd8ff32a2bf63e5f02d142 Mon Sep 17 00:00:00 2001 From: alexwes Date: Thu, 5 Sep 2024 21:43:40 -0400 Subject: [PATCH] Wormhole: EZ metrics + Txns (#465) --- .../wormhole/core/ez_wormhole_metrics.sql | 29 +++++++++++++++++++ .../staging/wormhole/fact_wormhole_txns.sql | 12 ++++++++ 2 files changed, 41 insertions(+) create mode 100644 models/projects/wormhole/core/ez_wormhole_metrics.sql create mode 100644 models/staging/wormhole/fact_wormhole_txns.sql diff --git a/models/projects/wormhole/core/ez_wormhole_metrics.sql b/models/projects/wormhole/core/ez_wormhole_metrics.sql new file mode 100644 index 00000000..31edcfc0 --- /dev/null +++ b/models/projects/wormhole/core/ez_wormhole_metrics.sql @@ -0,0 +1,29 @@ +{{ config( + materialized="table", + warehouse="WORMHOLE", + database="WORMHOLE", + schema="CORE", + alias="ez_metrics" +) }} + +with txns as ( + select + date, + txns + from {{ ref("fact_wormhole_txns") }} +) +, daa as ( + select + date, + bridge_daa + from {{ ref("fact_wormhole_bridge_daa_gold") }} +) + +select + coalesce(txns.date, daa.date) as date, + coalesce(txns.txns, 0) as txns, + coalesce(daa.bridge_daa, 0) as bridge_daa, + 0 as fees +from txns +left join daa on txns.date = daa.date +where coalesce(txns.date, daa.date) < to_date(sysdate()) diff --git a/models/staging/wormhole/fact_wormhole_txns.sql b/models/staging/wormhole/fact_wormhole_txns.sql new file mode 100644 index 00000000..8185c970 --- /dev/null +++ b/models/staging/wormhole/fact_wormhole_txns.sql @@ -0,0 +1,12 @@ +{{ config(materialized="table") }} + + +select + date(timestamp) as date, + count(distinct(id)) as txns +from + {{ ref("fact_wormhole_transfers") }} +group by + 1 +order by + 1 desc \ No newline at end of file