diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-17 21:07:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-17 21:07:17 +0300 |
commit | 3fbd6ba74ee268ad739599ae14dcf5c9b6acfc2c (patch) | |
tree | eea3db86df012fd59b4db8c4ec132e494bdac8fb /app/models/note.rb | |
parent | d41edc2e93480db35e48ad770ebe95075fbca871 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/note.rb')
-rw-r--r-- | app/models/note.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index e8c35ba33c7..73c8e72d8b0 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -134,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 |