2020-08-11 05:10:03 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ResourceTimeboxEvent < ResourceEvent
|
|
|
|
self.abstract_class = true
|
|
|
|
|
|
|
|
include IssueResourceEvent
|
|
|
|
include MergeRequestResourceEvent
|
2022-08-25 11:12:14 -04:00
|
|
|
include Importable
|
2020-08-11 05:10:03 -04:00
|
|
|
|
2022-08-25 11:12:14 -04:00
|
|
|
validate :exactly_one_issuable, unless: :importing?
|
2020-08-11 05:10:03 -04:00
|
|
|
|
|
|
|
enum action: {
|
|
|
|
add: 1,
|
|
|
|
remove: 2
|
|
|
|
}
|
|
|
|
|
2020-12-10 07:09:43 -05:00
|
|
|
after_create :issue_usage_metrics
|
2020-09-28 08:10:02 -04:00
|
|
|
|
2020-08-11 05:10:03 -04:00
|
|
|
def self.issuable_attrs
|
|
|
|
%i(issue merge_request).freeze
|
|
|
|
end
|
|
|
|
|
|
|
|
def issuable
|
|
|
|
issue || merge_request
|
|
|
|
end
|
2020-09-28 08:10:02 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-12-10 07:09:43 -05:00
|
|
|
def for_issue?
|
|
|
|
issue_id.present?
|
|
|
|
end
|
|
|
|
|
|
|
|
def issue_usage_metrics
|
|
|
|
return unless for_issue?
|
|
|
|
|
2020-09-28 08:10:02 -04:00
|
|
|
case self
|
|
|
|
when ResourceMilestoneEvent
|
2022-08-18 05:11:27 -04:00
|
|
|
Gitlab::UsageDataCounters::IssueActivityUniqueCounter.track_issue_milestone_changed_action(author: user,
|
|
|
|
project: issue.project)
|
2020-09-28 08:10:02 -04:00
|
|
|
else
|
|
|
|
# no-op
|
|
|
|
end
|
|
|
|
end
|
2020-08-11 05:10:03 -04:00
|
|
|
end
|
2020-11-06 13:09:07 -05:00
|
|
|
|
2021-05-11 17:10:21 -04:00
|
|
|
ResourceTimeboxEvent.prepend_mod_with('ResourceTimeboxEvent')
|