Skip to content

Commit

Permalink
add: timeseries funding_received sqlmesh model
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabolol committed Dec 3, 2024
1 parent b65daa3 commit 997c01e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions warehouse/metrics_mesh/models/metrics_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,15 @@
# ),
# entity_types=["artifact"],
# ),
"funding_received": MetricQueryDef(
ref="funding_received.sql",
rolling=RollingConfig(
windows=[180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
},
default_dialect="clickhouse",
)
14 changes: 14 additions & 0 deletions warehouse/metrics_mesh/oso_metrics/funding_received.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select @metrics_sample_date(events.bucket_day) as metrics_sample_date,
events.event_source,
events.to_artifact_id,
'' as from_artifact_id,
@metric_name() as metric,
SUM(events.amount) as amount
from metrics.events_daily_to_artifact as events
where event_type = 'CREDIT'
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE')
group by 1,
metric,
from_artifact_id,
to_artifact_id,
event_source

0 comments on commit 997c01e

Please sign in to comment.