diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /app/models/note.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index 052df6142c5..73c8e72d8b0 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -125,6 +125,7 @@ class Note < ApplicationRecord scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) } scope :system, -> { where(system: true) } scope :user, -> { where(system: false) } + scope :not_internal, -> { where(internal: false) } scope :common, -> { where(noteable_type: ["", nil]) } scope :fresh, -> { order_created_asc.with_order_id_asc } scope :updated_after, ->(time) { where('updated_at > ?', time) } @@ -133,9 +134,16 @@ class Note < ApplicationRecord scope :inc_author, -> { includes(:author) } scope :inc_note_diff_file, -> { includes(:note_diff_file) } scope :with_api_entity_associations, -> { preload(:note_diff_file, :author) } - scope :inc_relations_for_view, -> do - includes({ project: :group }, { author: :status }, :updated_by, :resolved_by, :award_emoji, - { system_note_metadata: :description_version }, :note_diff_file, :diff_note_positions, :suggestions) + scope :inc_relations_for_view, ->(noteable = nil) do + relations = [{ project: :group }, { author: :status }, :updated_by, :resolved_by, + :award_emoji, { system_note_metadata: :description_version }, :suggestions] + + if noteable.nil? || DiffNote.noteable_types.include?(noteable.class.name) || + Feature.disabled?(:skip_notes_diff_include) + relations += [:note_diff_file, :diff_note_positions] + end + + includes(relations) end scope :with_notes_filter, -> (notes_filter) do |