-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get response times and time to merge
- Loading branch information
Showing
7 changed files
with
132 additions
and
113 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
warehouse/metrics_mesh/models/code/issue_event_time_deltas.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
-- Model that records the delta (in seconds) since the creation of the issue or | ||
-- pr. | ||
MODEL ( | ||
name metrics.issue_event_time_deltas, | ||
kind VIEW | ||
); | ||
select `time`, | ||
event_type, | ||
event_source, | ||
@oso_id( | ||
event_source, | ||
to_artifact_id, | ||
issue_number | ||
) as issue_id, | ||
issue_number, | ||
to_artifact_id, | ||
from_artifact_id, | ||
created_at, | ||
merged_at, | ||
closed_at, | ||
date_diff('second', created_at, `time`) as created_delta, | ||
case | ||
when merged_at is null then null | ||
else date_diff('second', merged_at, `time`) | ||
end as merged_delta, | ||
case | ||
when closed_at is null then null | ||
else date_diff('second', closed_at, `time`) | ||
end as closed_delta, | ||
comments | ||
from @oso_source.timeseries_events_aux_issues_by_artifact_v0 |
22 changes: 22 additions & 0 deletions
22
warehouse/metrics_mesh/models/first_of_event_from_artifact.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MODEL ( | ||
name metrics.first_of_event_from_artifact, | ||
kind FULL, | ||
partitioned_by (day("time"), "event_type", "event_source"), | ||
grain ( | ||
time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
), | ||
); | ||
select MIN(time) as time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
from @oso_source.timeseries_events_by_artifact_v0 | ||
group by event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id |
22 changes: 22 additions & 0 deletions
22
warehouse/metrics_mesh/models/last_of_event_from_artifact.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
MODEL ( | ||
name metrics.last_of_event_from_artifact, | ||
kind FULL, | ||
partitioned_by (day("time"), "event_type", "event_source"), | ||
grain ( | ||
time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
), | ||
); | ||
select MAX(time) as time, | ||
event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id | ||
from @oso_source.timeseries_events_by_artifact_v0 | ||
group by event_type, | ||
event_source, | ||
from_artifact_id, | ||
to_artifact_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
select @metrics_sample_date(time) as metrics_sample_date, | ||
event_source, | ||
to_artifact_id, | ||
'' as from_artifact_id, | ||
@metric_name() as metric, | ||
AVG(created_delta) as amount | ||
from metrics.issue_event_time_deltas | ||
where event_type = 'PULL_REQUEST_MERGED' | ||
and `time` BETWEEN @metrics_start('DATE') and @metrics_end('DATE') | ||
group by 1, | ||
metric, | ||
from_artifact_id, | ||
to_artifact_id, | ||
event_source, |
98 changes: 20 additions & 78 deletions
98
warehouse/metrics_mesh/oso_metrics/time_to_first_response.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,23 @@ | ||
select | ||
@metrics_sample_date(time_to_first_response_events.responded_at) as metrics_sample_date, | ||
time_to_first_response_events.event_source, | ||
time_to_first_response_events.to_artifact_id, | ||
select @metrics_sample_date(time) as metrics_sample_date, | ||
event_source, | ||
to_artifact_id, | ||
'' as from_artifact_id, | ||
@metric_name() as metric, | ||
AVG(time_to_first_response_events.amount) as amount | ||
from ( | ||
select | ||
responded_at, | ||
to_artifact_id, | ||
event_source, | ||
time_to_first_response_days as amount | ||
from ( | ||
select | ||
start_events.issue_number, | ||
start_events.to_artifact_id, | ||
start_events.created_at, | ||
start_events.event_source, | ||
min(resp.responded_at) as responded_at, | ||
cast( | ||
timestamp_diff(min(resp.responded_at), start_events.created_at, minute) | ||
as float64 | ||
) / 60.0 / 24.0 as time_to_first_response_days | ||
from ( | ||
select | ||
issue_number, | ||
from_artifact_id as creator_id, | ||
to_artifact_id, | ||
time, | ||
event_type | ||
from metrics.timeseries_events_aux_issues_by_artifact_v0 | ||
where event_type in ('PULL_REQUEST_OPENED', 'ISSUE_OPENED') | ||
) as start_events | ||
inner join ( | ||
select | ||
issue_number, | ||
from_artifact_id as responder_id, | ||
to_artifact_id, | ||
time as responded_at, | ||
event_type | ||
from metrics.timeseries_events_aux_issues_by_artifact_v0 | ||
where event_type in ( | ||
'PULL_REQUEST_MERGED', | ||
'PULL_REQUEST_REVIEW_COMMENT', | ||
'ISSUE_CLOSED', | ||
'ISSUE_COMMENT' | ||
) | ||
) as resp_events | ||
on | ||
start_events.issue_number = resp_events.issue_number | ||
and start_events.to_artifact_id = resp_events.to_artifact_id | ||
and start_events.creator_id != resp_events.responder_id | ||
and ( | ||
( | ||
start_events.event_type = 'ISSUE_OPENED' | ||
and resp_events.event_type in ( | ||
'ISSUE_COMMENT', 'ISSUE_CLOSED' | ||
) | ||
) | ||
or | ||
( | ||
start_events.event_type = 'PULL_REQUEST_OPENED' | ||
and resp_events.event_type in ( | ||
'PULL_REQUEST_REVIEW_COMMENT', 'PULL_REQUEST_MERGED' | ||
) | ||
) | ||
) | ||
group by | ||
start_events.issue_number, | ||
start_events.to_artifact_id, | ||
start_events.created_at | ||
) as time_to_first_response | ||
) as time_to_first_response_events | ||
where time_to_first_response_events.responded_at BETWEEN @metrics_start('DATE') AND @metrics_end('DATE') | ||
group by | ||
metrics_sample_date, | ||
time_to_first_response_events.event_source, | ||
time_to_first_response_events.to_artifact_id, | ||
AVG(created_delta) as amount | ||
from metrics.issue_event_time_deltas | ||
where ( | ||
( | ||
event_type in ("PULL_REQUEST_MERGED", "ISSUE_CLOSED") | ||
and comments = 0 | ||
) | ||
or ( | ||
event_type in ("PULL_REQUEST_REVIEW_COMMENT", "ISSUE_COMMENT") | ||
and comments = 1 | ||
) | ||
) | ||
and `time` BETWEEN @metrics_start('DATE') and @metrics_end('DATE') | ||
group by 1, | ||
metric, | ||
from_artifact_id, | ||
metric | ||
to_artifact_id, | ||
event_source, |