html fixes and sort by number of todos logic

This commit is contained in:
waltercruz 2008-10-28 16:40:28 -02:00
parent 385f34d071
commit 0b57b23b2d
3 changed files with 15 additions and 7 deletions

View file

@ -188,7 +188,16 @@ class ProjectsController < ApplicationController
def actionize
@state = params['state']
@projects = current_user.projects.actionize(:state => @state) if @state
query_state = ''
query_state = 'AND project.state = "' + params['state'] +'" 'if @state
projects = Project.find_by_sql([
"SELECT project.id, count(todo.id) as p_count " +
"FROM projects as project " +
"LEFT OUTER JOIN todos as todo ON todo.project_id = project.id "+
"WHERE project.user_id = ? " +
query_state +
" GROUP BY project.id ORDER by p_count DESC",current_user.id])
@projects = current_user.projects.actionize(projects,:state => @state) if @state
@contexts = current_user.contexts
init_not_done_counts(['project'])
end