mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-22 08:46:11 +01:00
Ading a sort by number of tasks option
This commit is contained in:
parent
0673d67b62
commit
ee5c730f44
4 changed files with 30 additions and 1 deletions
|
|
@ -51,6 +51,12 @@ class User < ActiveRecord::Base
|
|||
self.update_positions(projects.map{ |p| p.id })
|
||||
return projects
|
||||
end
|
||||
def actionize(scope_conditions = {})
|
||||
projects = find(:all, :conditions => scope_conditions)
|
||||
projects.sort!{ |x,y| y.todos.count(:state == 'active') <=> x.todos.count(:state == 'active') }
|
||||
self.update_positions(projects.map{ |p| p.id })
|
||||
return projects
|
||||
end
|
||||
end
|
||||
has_many :active_projects,
|
||||
:class_name => 'Project',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue