Skip to content

Commit

Permalink
add: point in time and interval models
Browse files Browse the repository at this point in the history
  • Loading branch information
Jabolol authored and ravenac95 committed Nov 22, 2024
1 parent 0e73abf commit 4cd20d8
Show file tree
Hide file tree
Showing 8 changed files with 91 additions and 101 deletions.
80 changes: 73 additions & 7 deletions warehouse/metrics_mesh/models/metrics_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@
ref="gas_fees.sql",
time_aggregations=["daily", "weekly", "monthly"],
),
"repositories": MetricQueryDef(
ref="repositories.sql",
time_aggregations=["daily", "weekly", "monthly"],
),
"first_commit": MetricQueryDef(
ref="first_commit_date.sql",
time_aggregations=["daily", "weekly", "monthly"],
),
"last_commit": MetricQueryDef(
ref="last_commit_date.sql",
time_aggregations=["daily", "weekly", "monthly"],
),
"contributors": MetricQueryDef(
ref="contributors.sql",
time_aggregations=["daily", "weekly", "monthly"],
),
# This defines something with a rolling option that allows you to look back
# to some arbitrary window. So you specify the window and specify the unit.
# The unit and the window are used to pass in variables to the query. So it's
Expand Down Expand Up @@ -106,18 +122,68 @@
cron="@daily",
),
),
"developer_states": MetricQueryDef(
ref="developer_states.sql",
vars={
"full_time_ratio": 10 / 30,
},
"contributors_6_months": MetricQueryDef(
ref="contributors.sql",
rolling=RollingConfig(
windows=[30, 60, 90],
windows=[180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
"active_developers_6_months": MetricQueryDef(
ref="active_developers.sql",
rolling=RollingConfig(
windows=[180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
"commits_6_months": MetricQueryDef(
ref="commits.sql",
rolling=RollingConfig(
windows=[180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
"opened_pull_requests_6_months": MetricQueryDef(
ref="prs_opened.sql",
rolling=RollingConfig(
windows=[180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
"merged_pull_requests_6_months": MetricQueryDef(
ref="prs_merged.sql",
rolling=RollingConfig(
windows=[180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
"opened_issues_6_months": MetricQueryDef(
ref="issues_opened.sql",
rolling=RollingConfig(
windows=[180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
"closed_issues_6_months": MetricQueryDef(
ref="issues_closed.sql",
rolling=RollingConfig(
windows=[180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
is_intermediate=False,
),
},
default_dialect="clickhouse",
Expand Down
6 changes: 3 additions & 3 deletions warehouse/metrics_mesh/oso_metrics/active_developers.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
select @metrics_sample_date(events.bucket_day) as metrics_sample_date,
events.event_source,
events.to_artifact_id as project_id,
events.to_artifact_id as to_artifact_id,
'' as from_artifact_id,
@metric_name() as metric,
COUNT(distinct events.from_artifact_id) as amount
from metrics.events_daily_to_artifact as events
where events.event_type = 'COMMIT_CODE'
and events.bucket_day BETWEEN @metrics_start(DATE) AND @metrics_end(DATE)
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE')
group by 1,
metric,
from_artifact_id,
project_id,
to_artifact_id,
event_source
8 changes: 4 additions & 4 deletions warehouse/metrics_mesh/oso_metrics/contributors.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
select @metrics_sample_date(events.bucket_day) as metrics_sample_date,
events.event_source,
events.to_artifact_id as project_id,
events.to_artifact_id as to_artifact_id,
'' as from_artifact_id,
@metric_name() as metric,
COUNT(distinct events.from_artifact_id) as contributor_count
COUNT(distinct events.from_artifact_id) as amount
from metrics.events_daily_to_artifact as events
where events.event_type in (
'COMMIT_CODE',
'ISSUE_OPENED',
'PULL_REQUEST_OPENED',
'PULL_REQUEST_MERGED'
)
and events.bucket_day BETWEEN @metrics_start(DATE) AND @metrics_end(DATE)
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE')
group by 1,
metric,
from_artifact_id,
project_id,
to_artifact_id,
event_source
50 changes: 0 additions & 50 deletions warehouse/metrics_mesh/oso_metrics/developer_states.sql

This file was deleted.

7 changes: 4 additions & 3 deletions warehouse/metrics_mesh/oso_metrics/first_commit_date.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
select @metrics_sample_date(events.bucket_day) as metrics_sample_date,
events.event_source,
events.to_artifact_id as project_id,
events.to_artifact_id as to_artifact_id,
'' as from_artifact_id,
@metric_name() as metric,
1 as amount,
MIN(events.bucket_day) as first_commit_date
from metrics.events_daily_to_artifact as events
where events.event_type = 'COMMIT_CODE'
and events.bucket_day BETWEEN @metrics_start(DATE) AND @metrics_end(DATE)
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE')
group by 1,
metric,
from_artifact_id,
project_id,
to_artifact_id,
event_source
7 changes: 4 additions & 3 deletions warehouse/metrics_mesh/oso_metrics/last_commit_date.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
select @metrics_sample_date(events.bucket_day) as metrics_sample_date,
events.event_source,
events.to_artifact_id as project_id,
events.to_artifact_id as to_artifact_id,
'' as from_artifact_id,
@metric_name() as metric,
1 as amount,
MAX(events.bucket_day) as last_commit_date
from metrics.events_daily_to_artifact as events
where events.event_type = 'COMMIT_CODE'
and events.bucket_day BETWEEN @metrics_start(DATE) AND @metrics_end(DATE)
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE')
group by 1,
metric,
from_artifact_id,
project_id,
to_artifact_id,
event_source
28 changes: 0 additions & 28 deletions warehouse/metrics_mesh/oso_metrics/new_contributors.sql

This file was deleted.

6 changes: 3 additions & 3 deletions warehouse/metrics_mesh/oso_metrics/repositories.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
select @metrics_sample_date(events.bucket_day) as metrics_sample_date,
events.event_source,
events.to_artifact_id as project_id,
events.to_artifact_id as to_artifact_id,
'' as from_artifact_id,
@metric_name() as metric,
COUNT(distinct events.to_artifact_id) as amount
Expand All @@ -17,9 +17,9 @@ where events.event_type in (
'PULL_REQUEST_MERGED',
'ISSUE_CLOSED',
)
and events.bucket_day BETWEEN @metrics_start(DATE) AND @metrics_end(DATE)
and events.bucket_day BETWEEN @metrics_start('DATE') AND @metrics_end('DATE')
group by 1,
metric,
from_artifact_id,
project_id,
to_artifact_id,
event_source

0 comments on commit 4cd20d8

Please sign in to comment.