diff --git a/app/controllers/contexts_controller.rb b/app/controllers/contexts_controller.rb index db025cfa..476e69ef 100644 --- a/app/controllers/contexts_controller.rb +++ b/app/controllers/contexts_controller.rb @@ -225,15 +225,7 @@ class ContextsController < ApplicationController def render_autocomplete lambda do - # find contexts and the todos count. use a join to prevent all count(todos) of each context to be fetched - context_and_todo_count = current_user.contexts - .select('contexts.*, count(todos.id) as todos_count') - .joins('left outer join todos on context_id=contexts.id') - .group('context_id') - - filled_contexts = context_and_todo_count.reject { |ctx| ctx.todos.size == 0 } - empty_contexts = context_and_todo_count.find_all { |ctx| ctx.todos.size == 0 } - render :text => for_autocomplete(filled_contexts + empty_contexts, params[:term]) + render :text => for_autocomplete(current_user.contexts, params[:term]) end end