2018-11-20 20:47:30 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-05-18 00:54:41 +05:30
|
|
|
class Issue::Metrics < ApplicationRecord
|
2016-09-29 09:46:39 +05:30
|
|
|
belongs_to :issue
|
|
|
|
|
|
|
|
def record!
|
|
|
|
if issue.milestone_id.present? && self.first_associated_with_milestone_at.blank?
|
|
|
|
self.first_associated_with_milestone_at = Time.now
|
|
|
|
end
|
|
|
|
|
|
|
|
if issue_assigned_to_list_label? && self.first_added_to_board_at.blank?
|
|
|
|
self.first_added_to_board_at = Time.now
|
|
|
|
end
|
|
|
|
|
|
|
|
self.save
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def issue_assigned_to_list_label?
|
|
|
|
issue.labels.any? { |label| label.lists.present? }
|
|
|
|
end
|
|
|
|
end
|