gitlab-org--gitlab-foss/app/models/merge_request/metrics.rb
Timothy Andrew 487906b386 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.
2016-08-26 16:28:20 +05:30

15 lines
459 B
Ruby

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