diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-25 11:39:48 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 13:58:20 +0300 |
commit | d3fef0fb18759076ae6d189437b323aadd03fcf1 (patch) | |
tree | a251d9866c71eeea5745bb9695097fcb4e36f2b0 /app/models/cycle_analytics | |
parent | 14d6317ebc756ee6b27a3a8cd39927238f6d757c (diff) |
Add the "Staging" cycle analytics section.
Diffstat (limited to 'app/models/cycle_analytics')
-rw-r--r-- | app/models/cycle_analytics/queries.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/app/models/cycle_analytics/queries.rb b/app/models/cycle_analytics/queries.rb index 41081a4e08c..9970941837d 100644 --- a/app/models/cycle_analytics/queries.rb +++ b/app/models/cycle_analytics/queries.rb @@ -1,6 +1,10 @@ class CycleAnalytics module Queries class << self + def merge_requests_closing_issues(issues) + issues.map { |issue| issue.closed_by_merge_requests(nil, check_if_open: false) }.flatten + end + def issue_first_associated_with_milestone_or_first_added_to_list_label_time lambda do |issue| if issue.metrics.present? @@ -18,6 +22,24 @@ class CycleAnalytics end end + def mr_merged_at + lambda do |merge_request| + if merge_request.metrics.present? + merge_request.metrics.merged_at + end + end + end + + def mr_deployed_to_any_environment_at + lambda do |merge_request| + if merge_request.metrics.present? + deployments = Deployment.where(ref: merge_request.target_branch).where("created_at > ?", merge_request.metrics.merged_at) + deployment = deployments.order(:created_at).first + deployment.created_at if deployment + end + end + end + def issue_closing_merge_request_opened_time lambda do |issue| merge_requests = issue.closed_by_merge_requests(nil, check_if_open: false) |