diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-25 14:36:01 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 16:28:20 +0530 |
commit | 3d5729a7008f4ae62190a7862873fc6f28f33425 (patch) | |
tree | 9fcf78c21f42053dc5820f4634f3bfb9f5f011d6 /app/models/cycle_analytics.rb | |
parent | d3fef0fb18759076ae6d189437b323aadd03fcf1 (diff) | |
download | gitlab-ce-3d5729a7008f4ae62190a7862873fc6f28f33425.tar.gz |
Add the "Production" cycle analytics section.
1. Rewrite the `Queries` module to work off a `data_point` hash, with
`issue` and `merge_request` as keys. The "production" query needs
both an issue and a merge request to make it's calculation, so it
makes sense to keep things consistent and provide the same
data (issue + merge request) for all queries.
Diffstat (limited to 'app/models/cycle_analytics.rb')
-rw-r--r-- | app/models/cycle_analytics.rb | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb index 8ba275dd13a..2caccdce9a2 100644 --- a/app/models/cycle_analytics.rb +++ b/app/models/cycle_analytics.rb @@ -1,39 +1,40 @@ class CycleAnalytics def issue - issues = Issue.includes(:metrics).where("issue_metrics.id IS NOT NULL").references(:issue_metrics).to_a - start_time_fn = -> (issue) { issue.created_at } - calculate_metric(issues, start_time_fn, Queries::issue_first_associated_with_milestone_or_first_added_to_list_label_time) + calculate_metric(Queries::issues, + -> (data_point) { data_point[:issue].created_at }, + Queries::issue_first_associated_with_milestone_or_first_added_to_list_label_time) end def plan - issues = Issue.includes(:metrics).where("issue_metrics.id IS NOT NULL").references(:issue_metrics).to_a - calculate_metric(issues, + calculate_metric(Queries::issues, Queries::issue_first_associated_with_milestone_or_first_added_to_list_label_time, Queries::issue_closing_merge_request_opened_time) end def code - issues = Issue.all.to_a - start_time_fn = -> (merge_request) { merge_request.created_at } - calculate_metric(Queries::merge_requests_closing_issues(issues), - start_time_fn, + calculate_metric(Queries::merge_requests_closing_issues, + -> (data_point) { data_point[:merge_request].created_at }, Queries::mr_wip_flag_removed_or_assigned_to_user_other_than_author_time) end def review - issues = Issue.all.to_a - calculate_metric(Queries::merge_requests_closing_issues(issues), + calculate_metric(Queries::merge_requests_closing_issues, Queries::mr_wip_flag_removed_or_assigned_to_user_other_than_author_time, Queries::mr_first_closed_or_merged_at) end def staging - issues = Issue.all.to_a - calculate_metric(Queries::merge_requests_closing_issues(issues), + calculate_metric(Queries::merge_requests_closing_issues, Queries::mr_merged_at, Queries::mr_deployed_to_any_environment_at) end + def production + calculate_metric(Queries::merge_requests_closing_issues, + -> (data_point) { data_point[:issue].created_at }, + Queries::mr_deployed_to_production_at) + end + private def calculate_metric(data, start_time_fn, end_time_fn) |