diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-25 15:04:12 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 16:28:20 +0530 |
commit | ebc03833f27528de3e59e46dc8390b293f3657bf (patch) | |
tree | 8c27b84e8be0c1a5af681892786b6c92893053c4 /app/models/cycle_analytics | |
parent | fc92d066356c2becf8db74e0cc0832f2bca2b930 (diff) | |
download | gitlab-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')
-rw-r--r-- | app/models/cycle_analytics/queries.rb | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/app/models/cycle_analytics/queries.rb b/app/models/cycle_analytics/queries.rb index efdacc28638..1074b62039b 100644 --- a/app/models/cycle_analytics/queries.rb +++ b/app/models/cycle_analytics/queries.rb @@ -12,35 +12,35 @@ class CycleAnalytics end.flatten end - def issue_first_associated_with_milestone_or_first_added_to_list_label_time + def issue_first_associated_with_milestone_at lambda do |data_point| issue = data_point[:issue] - if issue.metrics.present? - issue.metrics.first_associated_with_milestone_at.presence || - issue.metrics.first_added_to_board_at.presence - end + issue.metrics.first_associated_with_milestone_at if issue.metrics.present? end end - def mr_first_closed_or_merged_at + def issue_first_added_to_list_label_at + lambda do |data_point| + issue = data_point[:issue] + issue.metrics.first_added_to_board_at if issue.metrics.present? + end + end + + def merge_request_first_closed_at lambda do |data_point| merge_request = data_point[:merge_request] - if merge_request.metrics.present? - merge_request.metrics.merged_at.presence || merge_request.metrics.first_closed_at.presence - end + merge_request.metrics.first_closed_at if merge_request.metrics.present? end end - def mr_merged_at + def merge_request_merged_at lambda do |data_point| merge_request = data_point[:merge_request] - if merge_request.metrics.present? - merge_request.metrics.merged_at - end + merge_request.metrics.merged_at if merge_request.metrics.present? end end - def mr_build_started_at + def merge_request_build_started_at lambda do |data_point| merge_request = data_point[:merge_request] tip = merge_request.commits.first @@ -51,7 +51,7 @@ class CycleAnalytics end end - def mr_build_finished_at + def merge_request_build_finished_at lambda do |data_point| merge_request = data_point[:merge_request] tip = merge_request.commits.first @@ -62,7 +62,7 @@ class CycleAnalytics end end - def mr_deployed_to_any_environment_at + def merge_request_deployed_to_any_environment_at lambda do |data_point| merge_request = data_point[:merge_request] if merge_request.metrics.present? @@ -73,7 +73,7 @@ class CycleAnalytics end end - def mr_deployed_to_production_at + def merge_request_deployed_to_production_at lambda do |data_point| merge_request = data_point[:merge_request] if merge_request.metrics.present? @@ -85,7 +85,7 @@ class CycleAnalytics end end - def issue_closing_merge_request_opened_time + def issue_closing_merge_request_opened_at lambda do |data_point| issue = data_point[:issue] merge_requests = issue.closed_by_merge_requests(nil, check_if_open: false) @@ -93,13 +93,17 @@ class CycleAnalytics end end - def mr_wip_flag_removed_or_assigned_to_user_other_than_author_time + def merge_request_wip_flag_first_removed_at lambda do |data_point| merge_request = data_point[:merge_request] - if merge_request.metrics.present? - merge_request.metrics.wip_flag_first_removed_at.presence || - merge_request.metrics.first_assigned_to_user_other_than_author.presence - end + merge_request.metrics.wip_flag_first_removed_at if merge_request.metrics.present? + end + end + + def merge_request_first_assigned_to_user_other_than_author_at + lambda do |data_point| + merge_request = data_point[:merge_request] + merge_request.metrics.first_assigned_to_user_other_than_author if merge_request.metrics.present? end end end |