Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: timeseries funding_received sqlmesh model #2563

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading