diff options
Diffstat (limited to 'app/models/event.rb')
-rw-r--r-- | app/models/event.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/event.rb b/app/models/event.rb index 447ab753421..12b85697690 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -96,6 +96,8 @@ class Event < ApplicationRecord end scope :for_milestone_id, ->(milestone_id) { where(target_type: "Milestone", target_id: milestone_id) } + scope :for_wiki_meta, ->(meta) { where(target_type: 'WikiPage::Meta', target_id: meta.id) } + scope :created_at, ->(time) { where(created_at: time) } # Authors are required as they're used to display who pushed data. # @@ -313,6 +315,10 @@ class Event < ApplicationRecord note? && target && target.for_personal_snippet? end + def design_note? + note? && note.for_design? + end + def note_target target.noteable end @@ -380,6 +386,11 @@ class Event < ApplicationRecord protected + # rubocop:disable Metrics/CyclomaticComplexity + # rubocop:disable Metrics/PerceivedComplexity + # + # TODO Refactor this method so we no longer need to disable the above cops + # https://gitlab.com/gitlab-org/gitlab/-/issues/216879. def capability @capability ||= begin if push_action? || commit_note? @@ -396,9 +407,13 @@ class Event < ApplicationRecord :read_milestone elsif wiki_page? :read_wiki + elsif design_note? + :read_design end end end + # rubocop:enable Metrics/CyclomaticComplexity + # rubocop:enable Metrics/PerceivedComplexity private |