summaryrefslogtreecommitdiff
path: root/app/models/cycle_analytics.rb
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-08-25 15:04:12 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-08-26 16:28:20 +0530
commitebc03833f27528de3e59e46dc8390b293f3657bf (patch)
tree8c27b84e8be0c1a5af681892786b6c92893053c4 /app/models/cycle_analytics.rb
parentfc92d066356c2becf8db74e0cc0832f2bca2b930 (diff)
downloadgitlab-ce-ebc03833f27528de3e59e46dc8390b293f3657bf.tar.gz
Allow multiple queries for each cycle analytics section.
1. Pass in an array of queries - the first to return a value will be used. This makes it easier to add more heuristics later. 2. Convert all queries with 'or' in the title to two separate queries. 3. Rename all `mr_` methods to `merge_request_`
Diffstat (limited to 'app/models/cycle_analytics.rb')
-rw-r--r--app/models/cycle_analytics.rb28
1 files changed, 14 insertions, 14 deletions
diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb
index 8b791e1e9ac..34a841ff5ce 100644
--- a/app/models/cycle_analytics.rb
+++ b/app/models/cycle_analytics.rb
@@ -2,51 +2,51 @@ class CycleAnalytics
def issue
calculate_metric(Queries::issues,
-> (data_point) { data_point[:issue].created_at },
- Queries::issue_first_associated_with_milestone_or_first_added_to_list_label_time)
+ [Queries::issue_first_associated_with_milestone_at, Queries::issue_first_added_to_list_label_at])
end
def plan
calculate_metric(Queries::issues,
- Queries::issue_first_associated_with_milestone_or_first_added_to_list_label_time,
- Queries::issue_closing_merge_request_opened_time)
+ [Queries::issue_first_associated_with_milestone_at, Queries::issue_first_added_to_list_label_at],
+ Queries::issue_closing_merge_request_opened_at)
end
def code
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)
+ [Queries::merge_request_first_assigned_to_user_other_than_author_at, Queries::merge_request_wip_flag_first_removed_at])
end
def test
calculate_metric(Queries::merge_requests_closing_issues,
- Queries::mr_build_started_at,
- Queries::mr_build_finished_at)
+ Queries::merge_request_build_started_at,
+ Queries::merge_request_build_finished_at)
end
def review
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)
+ [Queries::merge_request_first_assigned_to_user_other_than_author_at, Queries::merge_request_wip_flag_first_removed_at],
+ [Queries::merge_request_first_closed_at, Queries::merge_request_merged_at])
end
def staging
calculate_metric(Queries::merge_requests_closing_issues,
- Queries::mr_merged_at,
- Queries::mr_deployed_to_any_environment_at)
+ Queries::merge_request_merged_at,
+ Queries::merge_request_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)
+ Queries::merge_request_deployed_to_production_at)
end
private
- def calculate_metric(data, start_time_fn, end_time_fn)
+ def calculate_metric(data, start_time_fns, end_time_fns)
times = data.map do |data_point|
- start_time = start_time_fn[data_point]
- end_time = end_time_fn[data_point]
+ start_time = Array.wrap(start_time_fns).map { |fn| fn[data_point] }.compact.first
+ end_time = Array.wrap(end_time_fns).map { |fn| fn[data_point] }.compact.first
if start_time.present? && end_time.present?
end_time - start_time