Skip to content

Commit

Permalink
Merge branch 'main' into gitcoin/updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ccerv1 authored Dec 3, 2024
2 parents 4998d87 + 483b62a commit 93d72c3
Show file tree
Hide file tree
Showing 13 changed files with 574 additions and 122 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
MODEL (
name metrics.events_daily_to_artifact_with_lag,
kind FULL,
start '2015-01-01',
cron '@daily',
partitioned_by (day("bucket_day"), "event_type"),
grain (
bucket_day,
event_type,
event_source,
from_artifact_id,
to_artifact_id
),
);
SELECT bucket_day,
to_artifact_id,
from_artifact_id,
event_source,
event_type,
amount,
LAG(bucket_day) OVER (
PARTITION BY to_artifact_id,
from_artifact_id,
event_source,
event_type
ORDER BY bucket_day
) AS last_event
FROM metrics.events_daily_to_artifact
133 changes: 90 additions & 43 deletions warehouse/metrics_mesh/models/metrics_factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
model_prefix="timeseries",
timeseries_sources=[
"events_daily_to_artifact",
"events_daily_to_artifact_with_lag",
"issue_event_time_deltas",
"first_of_event_from_artifact",
],
metric_queries={
# This will automatically generate star counts for the given roll up periods.
Expand Down Expand Up @@ -76,68 +78,70 @@
entity_types=["artifact", "project", "collection"],
is_intermediate=True,
),
"developer_classifications": MetricQueryDef(
ref="developer_activity_classification.sql",
"contributor_active_days": MetricQueryDef(
ref="active_days.sql",
vars={
"full_time_ratio": 10 / 30,
"activity_event_types": [
"COMMIT_CODE",
"ISSUE_OPENED",
"PULL_REQUEST_OPENED",
"PULL_REQUEST_MERGED",
],
},
rolling=RollingConfig(
windows=[30, 90, 180],
unit="day",
cron="@daily",
),
),
"contributor_classifications": MetricQueryDef(
ref="contributor_activity_classification.sql",
vars={"full_time_ratio": 10 / 30},
rolling=RollingConfig(
windows=[30, 90, 180],
unit="day",
cron="@daily",
cron="@daily", # This determines how often this is calculated
),
entity_types=["artifact", "project", "collection"],
is_intermediate=True,
),
"user_retention_classifications": MetricQueryDef(
ref="user_retention_classification.sql",
"developer_classifications": MetricQueryDef(
ref="developer_activity_classification.sql",
vars={
"activity_event_types": ["CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT"],
"full_time_ratio": 10 / 30,
},
rolling=RollingConfig(
windows=[30, 90, 180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
"change_in_30_day_developer_activity": MetricQueryDef(
vars={
"comparison_interval": 30,
},
ref="change_in_developers.sql",
rolling=RollingConfig(
windows=[2],
unit="period",
cron="@daily",
),
),
"change_in_90_day_developer_activity": MetricQueryDef(
"contributor_classifications": MetricQueryDef(
ref="contributor_activity_classification.sql",
vars={
"comparison_interval": 90,
"full_time_ratio": 10 / 30,
"activity_event_types": [
"COMMIT_CODE",
"ISSUE_OPENED",
"PULL_REQUEST_OPENED",
"PULL_REQUEST_MERGED",
],
},
ref="change_in_developers.sql",
rolling=RollingConfig(
windows=[2],
unit="period",
windows=[30, 90, 180],
unit="day",
cron="@daily",
),
),
"change_in_180_day_developer_activity": MetricQueryDef(
vars={
"comparison_interval": 180,
},
# Currently this query performs really poorly. We need to do some debugging on it
# "user_retention_classifications": MetricQueryDef(
# ref="user_retention_classification.sql",
# vars={
# "activity_event_types": ["CONTRACT_INVOCATION_SUCCESS_DAILY_COUNT"],
# },
# rolling=RollingConfig(
# windows=[30, 90, 180],
# unit="day",
# cron="@daily",
# ),
# entity_types=["artifact", "project", "collection"],
# ),
"change_in_developer_activity": MetricQueryDef(
ref="change_in_developers.sql",
rolling=RollingConfig(
windows=[2],
unit="period",
windows=[30, 90, 180],
unit="day",
cron="@daily",
),
),
Expand Down Expand Up @@ -195,8 +199,8 @@
),
entity_types=["artifact", "project", "collection"],
),
"avg_time_to_first_response": MetricQueryDef(
ref="prs_time_to_merge.sql",
"avg_time_to_first_response": MetricQueryDef(
ref="time_to_first_response.sql",
rolling=RollingConfig(
windows=[90, 180],
unit="day",
Expand Down Expand Up @@ -230,7 +234,7 @@
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
),
"transactions": MetricQueryDef(
ref="transactions.sql",
rolling=RollingConfig(
Expand All @@ -239,7 +243,50 @@
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
),
"contributors_lifecycle": MetricQueryDef(
ref="lifecycle.sql",
vars={
"activity_event_types": [
"COMMIT_CODE",
"ISSUE_OPENED",
"PULL_REQUEST_OPENED",
"PULL_REQUEST_MERGED",
],
},
rolling=RollingConfig(
windows=[30, 90, 180],
unit="day",
cron="@daily",
),
entity_types=["artifact", "project", "collection"],
),
# "libin": MetricQueryDef(
# ref="libin.sql",
# vars={
# "activity_event_types": [
# "COMMIT_CODE",
# "ISSUE_OPENED",
# "PULL_REQUEST_OPENED",
# "PULL_REQUEST_MERGED",
# ],
# },
# rolling=RollingConfig(
# windows=[30, 90, 180],
# unit="day",
# cron="@daily",
# ),
# 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",
)
16 changes: 8 additions & 8 deletions warehouse/metrics_mesh/oso_metrics/change_in_developers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ WITH latest AS (
classification.amount
FROM @metrics_peer_ref(
developer_classifications,
window := @comparison_interval,
unit := 'day',
window := @rolling_window,
unit := @rolling_unit,
) as classification
WHERE classification.metrics_sample_date = @relative_window_sample_date(
@metrics_end('DATE'),
@comparison_interval,
'day',
@rolling_window,
@rolling_unit,
0
)
),
Expand All @@ -31,13 +31,13 @@ previous AS (
classification.amount
FROM @metrics_peer_ref(
developer_classifications,
window := @comparison_interval,
unit := 'day'
window := @rolling_window,
unit := @rolling_unit
) as classification
WHERE classification.metrics_sample_date = @relative_window_sample_date(
@metrics_end('DATE'),
@comparison_interval,
'day',
@rolling_window,
@rolling_unit,
-1
)
)
Expand Down
Loading

0 comments on commit 93d72c3

Please sign in to comment.