diff options
author | Sean McGivern <sean@gitlab.com> | 2018-03-05 16:41:48 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-03-05 16:42:51 +0000 |
commit | 631eed028bffc55f0a80b72ab3598bc73e49272b (patch) | |
tree | 308d458f0a934ae2ad4893c7fc87483a2fab22b8 /app/models/todo.rb | |
parent | fc9955ce8da200e58fe8fcfef68f02344bfd8390 (diff) | |
download | gitlab-ce-631eed028bffc55f0a80b72ab3598bc73e49272b.tar.gz |
Remove default scope from todosremove-default-scope-from-todos
This was causing todo priority sorting to fail.
Diffstat (limited to 'app/models/todo.rb')
-rw-r--r-- | app/models/todo.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/app/models/todo.rb b/app/models/todo.rb index bb5965e20eb..8afacd188e0 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -32,8 +32,6 @@ class Todo < ActiveRecord::Base validates :target_id, presence: true, unless: :for_commit? validates :commit_id, presence: true, if: :for_commit? - default_scope { reorder(id: :desc) } - scope :pending, -> { with_state(:pending) } scope :done, -> { with_state(:done) } @@ -53,10 +51,14 @@ class Todo < ActiveRecord::Base # milestones, but still show something if the user has a URL with that # selected. def sort(method) - case method.to_s - when 'priority', 'label_priority' then order_by_labels_priority - else order_by(method) - end + sorted = + case method.to_s + when 'priority', 'label_priority' then order_by_labels_priority + else order_by(method) + end + + # Break ties with the ID column for pagination + sorted.order(id: :desc) end # Order by priority depending on which issue/merge request the Todo belongs to |