From df8dd50440c726b4f2c02cafcb41c40126de167a Mon Sep 17 00:00:00 2001 From: Carl Cervone <42869436+ccerv1@users.noreply.github.com> Date: Sun, 8 Sep 2024 13:02:07 -0400 Subject: [PATCH] test: forks metric (#2100) --- warehouse/metrics_mesh/models/metrics_factories.py | 4 ++++ warehouse/metrics_mesh/oso_metrics/forks.sql | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 warehouse/metrics_mesh/oso_metrics/forks.sql diff --git a/warehouse/metrics_mesh/models/metrics_factories.py b/warehouse/metrics_mesh/models/metrics_factories.py index 474852e9c..29e67f075 100644 --- a/warehouse/metrics_mesh/models/metrics_factories.py +++ b/warehouse/metrics_mesh/models/metrics_factories.py @@ -35,6 +35,10 @@ ref="stars.sql", vars={}, ), + "forks": MetricQuery( + ref="forks.sql", + vars={}, + ), }, trailing_days=30, model_options=dict( diff --git a/warehouse/metrics_mesh/oso_metrics/forks.sql b/warehouse/metrics_mesh/oso_metrics/forks.sql new file mode 100644 index 000000000..e353bacd3 --- /dev/null +++ b/warehouse/metrics_mesh/oso_metrics/forks.sql @@ -0,0 +1,14 @@ +select STR_TO_DATE(@end_ds, '%Y-%m-%d') as metrics_bucket_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 in ('FORKED') + and events.bucket_day BETWEEN STR_TO_DATE(@start_ds, '%Y-%m-%d') AND STR_TO_DATE(@end_ds, '%Y-%m-%d') +group by 1, + metric, + from_artifact_id, + to_artifact_id, + event_source \ No newline at end of file