diff options
author | Sean McGivern <sean@gitlab.com> | 2018-03-05 19:41:48 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2018-03-05 19:42:51 +0300 |
commit | 631eed028bffc55f0a80b72ab3598bc73e49272b (patch) | |
tree | 308d458f0a934ae2ad4893c7fc87483a2fab22b8 /app | |
parent | fc9955ce8da200e58fe8fcfef68f02344bfd8390 (diff) |
Remove default scope from todos
This was causing todo priority sorting to fail.
Diffstat (limited to 'app')
-rw-r--r-- | app/finders/todos_finder.rb | 4 | ||||
-rw-r--r-- | app/models/todo.rb | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb index 47c8b9b60ed..150f4c7688b 100644 --- a/app/finders/todos_finder.rb +++ b/app/finders/todos_finder.rb @@ -150,9 +150,7 @@ class TodosFinder if project? items.where(project: project) else - projects = Project - .public_or_visible_to_user(current_user) - .order_id_desc + projects = Project.public_or_visible_to_user(current_user) items.joins(:project).merge(projects) end 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 |