diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-18 18:09:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-18 18:09:04 +0300 |
commit | dfda8b7e77835fc54d469eda336b13b415365703 (patch) | |
tree | b94d991d464dc1e98f0f365e1e15e94c3ee8c9ca /app/models/note.rb | |
parent | 19d46f60a3699232458357111365e63a8c71f20d (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, 11 insertions, 2 deletions
diff --git a/app/models/note.rb b/app/models/note.rb index fb540d692d1..c75d6aa77e6 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -19,6 +19,7 @@ class Note < ApplicationRecord include Gitlab::SQL::Pattern include ThrottledTouch include FromUnion + include Sortable cache_markdown_field :note, pipeline: :note, issuable_state_filter_enabled: true @@ -103,10 +104,9 @@ class Note < ApplicationRecord scope :system, -> { where(system: true) } scope :user, -> { where(system: false) } scope :common, -> { where(noteable_type: ["", nil]) } - scope :fresh, -> { order(created_at: :asc, id: :asc) } + scope :fresh, -> { order_created_asc.with_order_id_asc } scope :updated_after, ->(time) { where('updated_at > ?', time) } scope :with_updated_at, ->(time) { where(updated_at: time) } - scope :by_updated_at, -> { reorder(:updated_at, :id) } scope :inc_author_project, -> { includes(:project, :author) } scope :inc_author, -> { includes(:author) } scope :inc_relations_for_view, -> do @@ -148,6 +148,8 @@ class Note < ApplicationRecord after_commit :notify_after_destroy, on: :destroy class << self + extend Gitlab::Utils::Override + def model_name ActiveModel::Name.new(self, nil, 'note') end @@ -204,6 +206,13 @@ class Note < ApplicationRecord def search(query) fuzzy_search(query, [:note]) end + + # Override the `Sortable` module's `.simple_sorts` to remove name sorting, + # as a `Note` does not have any property that correlates to a "name". + override :simple_sorts + def simple_sorts + super.except('name_asc', 'name_desc') + end end # rubocop: disable CodeReuse/ServiceClass |