diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 03:07:41 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-02 03:07:41 +0300 |
commit | 42263d6451c0af3c0e7a61747ffb046a806e4477 (patch) | |
tree | 989941de7bbf543963942e7d9a4b1b89bdf7e386 /app/models/resource_label_event.rb | |
parent | 2412ddf03da787012161ea1e8a03787275f9cde9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/resource_label_event.rb')
-rw-r--r-- | app/models/resource_label_event.rb | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/app/models/resource_label_event.rb b/app/models/resource_label_event.rb index 59907f1b962..970d4e1e562 100644 --- a/app/models/resource_label_event.rb +++ b/app/models/resource_label_event.rb @@ -1,10 +1,7 @@ # frozen_string_literal: true -class ResourceLabelEvent < ApplicationRecord - include Importable - include Gitlab::Utils::StrongMemoize +class ResourceLabelEvent < ResourceEvent include CacheMarkdownField - include ResourceEventTools cache_markdown_field :reference @@ -13,8 +10,11 @@ class ResourceLabelEvent < ApplicationRecord belongs_to :label scope :inc_relations, -> { includes(:label, :user) } + scope :by_issue, ->(issue) { where(issue_id: issue.id) } + scope :by_merge_request, ->(merge_request) { where(merge_request_id: merge_request.id) } validates :label, presence: { unless: :importing? }, on: :create + validate :exactly_one_issuable after_save :expire_etag_cache after_destroy :expire_etag_cache @@ -41,12 +41,6 @@ class ResourceLabelEvent < ApplicationRecord issue || merge_request end - def discussion_id(resource = nil) - strong_memoize(:discussion_id) do - Digest::SHA1.hexdigest(discussion_id_key.join("-")) - end - end - def project issuable.project end @@ -109,10 +103,6 @@ class ResourceLabelEvent < ApplicationRecord def resource_parent issuable.project || issuable.group end - - def discussion_id_key - [self.class.name, created_at, user_id] - end end ResourceLabelEvent.prepend_if_ee('EE::ResourceLabelEvent') |