From b1f54e68b8679ab79d80c280b71641402ee352ef Mon Sep 17 00:00:00 2001 From: Dan Rice Date: Sat, 9 Mar 2013 22:21:54 +0200 Subject: [PATCH] Use default context sort order when returning autocomplete Fixes #1403 --- app/controllers/contexts_controller.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) 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