diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-08-24 20:17:48 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-08-26 16:27:37 +0530 |
commit | 516c838a1846d049814765afa85c28a3c14a5b9f (patch) | |
tree | a9228fa421e8b03f7a0e6a7486375baa2d369f4d /app/models/issue | |
parent | 1bf2fe276ff084d3b2e0860710ec115a317dd9fc (diff) | |
download | gitlab-ce-516c838a1846d049814765afa85c28a3c14a5b9f.tar.gz |
Add an `Issue::Metrics` model.
- And store the `first_associated_with_milestone_at` and
`first_added_to_board_at` times, when an issue is saved.
Diffstat (limited to 'app/models/issue')
-rw-r--r-- | app/models/issue/metrics.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/app/models/issue/metrics.rb b/app/models/issue/metrics.rb new file mode 100644 index 00000000000..4436696cc1a --- /dev/null +++ b/app/models/issue/metrics.rb @@ -0,0 +1,21 @@ +class Issue::Metrics < ActiveRecord::Base + 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 if self.changed? + end + + private + + def issue_assigned_to_list_label? + issue.labels.any? { |label| label.lists.present? } + end +end |