summaryrefslogtreecommitdiff
path: root/app/models/concerns/work_item_resource_event.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /app/models/concerns/work_item_resource_event.rb
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
downloadgitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'app/models/concerns/work_item_resource_event.rb')
-rw-r--r--app/models/concerns/work_item_resource_event.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/models/concerns/work_item_resource_event.rb b/app/models/concerns/work_item_resource_event.rb
new file mode 100644
index 00000000000..d0323feb029
--- /dev/null
+++ b/app/models/concerns/work_item_resource_event.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module WorkItemResourceEvent
+ extend ActiveSupport::Concern
+
+ included do
+ belongs_to :work_item, foreign_key: 'issue_id'
+ end
+
+ def work_item_synthetic_system_note(events: nil)
+ # System notes for label resource events are handled in batches, so that we have single system note for multiple
+ # label changes.
+ if is_a?(ResourceLabelEvent) && events.present?
+ return synthetic_note_class.from_events(events, resource: work_item, resource_parent: work_item.project)
+ end
+
+ synthetic_note_class.from_event(self, resource: work_item, resource_parent: work_item.project)
+ end
+
+ def synthetic_note_class
+ raise NoMethodError, 'must implement `synthetic_note_class` method'
+ end
+end