summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb14
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