diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-25 11:24:41 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 16:28:20 +0530 |
commit | 487906b3861068a8f81125814f919a07bfab8469 (patch) | |
tree | 13bb6d62ad6211c2f7075e0d1321f5405acbfeb0 /app/models/cycle_analytics | |
parent | f932bb8e41852d7bdcd66fe15a56277074df3aa3 (diff) | |
download | gitlab-ce-487906b3861068a8f81125814f919a07bfab8469.tar.gz |
Add the "Code" Cycle Analytics section.
1. Record the `wip_flag_first_removed_at` and
`first_assigned_to_user_other_than_author` metrics for a merge
request. Use a `merge_request_metrics` table, similar to the one for
`issues`. Metrics are recorded `after_save`.
2. Move larger queries to a `CycleAnalytics::Queries` module.
Diffstat (limited to 'app/models/cycle_analytics')
-rw-r--r-- | app/models/cycle_analytics/queries.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/app/models/cycle_analytics/queries.rb b/app/models/cycle_analytics/queries.rb new file mode 100644 index 00000000000..ec0311b91b5 --- /dev/null +++ b/app/models/cycle_analytics/queries.rb @@ -0,0 +1,26 @@ +class CycleAnalytics + module Queries + class << self + def issue_first_associated_with_milestone_or_first_added_to_list_label_time + lambda do |issue| + issue.metrics.first_associated_with_milestone_at.presence || issue.metrics.first_added_to_board_at.presence + end + end + + def issue_closing_merge_request_opened_time + lambda do |issue| + merge_requests = issue.closed_by_merge_requests + merge_requests.map(&:created_at).min if merge_requests.present? + end + end + + def mr_wip_flag_removed_or_assigned_to_user_other_than_author_time + lambda do |merge_request| + if merge_request.metrics.present? + merge_request.metrics.wip_flag_first_removed_at || merge_request.metrics.first_assigned_to_user_other_than_author + end + end + end + end + end +end |