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