summaryrefslogtreecommitdiff
path: root/app/models/merge_request
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-08-25 11:24:41 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-08-26 16:28:20 +0530
commit487906b3861068a8f81125814f919a07bfab8469 (patch)
tree13bb6d62ad6211c2f7075e0d1321f5405acbfeb0 /app/models/merge_request
parentf932bb8e41852d7bdcd66fe15a56277074df3aa3 (diff)
downloadgitlab-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/merge_request')
-rw-r--r--app/models/merge_request/metrics.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/merge_request/metrics.rb b/app/models/merge_request/metrics.rb
new file mode 100644
index 00000000000..7f7cf95e388
--- /dev/null
+++ b/app/models/merge_request/metrics.rb
@@ -0,0 +1,15 @@
+class MergeRequest::Metrics < ActiveRecord::Base
+ belongs_to :merge_request
+
+ def record!
+ if !merge_request.work_in_progress? && self.wip_flag_first_removed_at.blank?
+ self.wip_flag_first_removed_at = Time.now
+ end
+
+ if merge_request.author_id != merge_request.assignee_id && self.first_assigned_to_user_other_than_author.blank?
+ self.first_assigned_to_user_other_than_author = Time.now
+ end
+
+ self.save if self.changed?
+ end
+end