mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-17 15:50:13 +01:00
Make User.projects.actionize deterministic
Add project.id to the comparison to ensure consistent order when counts are identical.
This commit is contained in:
parent
0d6e0efcee
commit
7f1246f42f
1 changed files with 1 additions and 1 deletions
|
|
@ -62,7 +62,7 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
def actionize(scope_conditions = {})
|
||||
todos_in_project = where(scope_conditions).includes(:todos)
|
||||
todos_in_project.to_a.sort!{ |x, y| -(x.todos.active.count <=> y.todos.active.count) }
|
||||
todos_in_project.to_a.sort_by!{ |x| [-x.todos.active.count, -x.id] }
|
||||
todos_in_project.reject{ |p| p.todos.active.count > 0 }
|
||||
sorted_project_ids = todos_in_project.map {|p| p.id}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue