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.rb | |
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.rb')
-rw-r--r-- | app/models/issue.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/issue.rb b/app/models/issue.rb index 788611305fe..1aa0cef884e 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -23,6 +23,8 @@ class Issue < ActiveRecord::Base has_many :events, as: :target, dependent: :destroy + has_one :metrics, dependent: :destroy + validates :project, presence: true scope :cared, ->(user) { where(assignee_id: user) } @@ -36,6 +38,8 @@ class Issue < ActiveRecord::Base scope :order_due_date_asc, -> { reorder('issues.due_date IS NULL, issues.due_date ASC') } scope :order_due_date_desc, -> { reorder('issues.due_date IS NULL, issues.due_date DESC') } + after_save :record_metrics + attr_spammable :title, spam_title: true attr_spammable :description, spam_description: true @@ -270,4 +274,9 @@ class Issue < ActiveRecord::Base def check_for_spam? project.public? end + + def record_metrics + metrics = Metrics.find_or_create_by(issue_id: self.id) + metrics.record! + end end |