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: libin diagram first iteration #2541

Merged
merged 14 commits into from
Dec 3, 2024
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
124 changes: 81 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,41 @@
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"],
# ),
},
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
Loading