mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
first select than sort
sorting on a smaller collection is faster
This commit is contained in:
parent
405ad5a79f
commit
d3aa73f783
1 changed files with 1 additions and 1 deletions
|
|
@ -34,7 +34,7 @@ class User < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
def projects_in_state_by_position(state)
|
||||
self.sort_by{ |p| p.position }.select{ |p| p.state == state }
|
||||
self.select{ |p| p.state == state }.sort_by{ |p| p.position }
|
||||
end
|
||||
def next_from(project)
|
||||
self.offset_from(project, 1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue