From 668b7e3e7054a8db81733681d0e760828528a740 Mon Sep 17 00:00:00 2001 From: Luke Baker Date: Tue, 6 Sep 2011 15:23:55 -0400 Subject: [PATCH] update index to not always return all questions --- app/controllers/questions_controller.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb index ee577d7..df2419b 100644 --- a/app/controllers/questions_controller.rb +++ b/app/controllers/questions_controller.rb @@ -294,8 +294,6 @@ class QuestionsController < InheritedResources::Base end def index - @questions = current_user.questions.scoped({}) - @questions = @questions.created_by(params[:creator]) if params[:creator] counts = {} if params[:user_ideas] @@ -314,6 +312,14 @@ class QuestionsController < InheritedResources::Base :group => "votes.question_id") end + # only return questions with these recent votes + if counts['recent-votes'] && params[:all] != 'true' + @questions = current_user.questions.scoped({}).find(counts['recent-votes'].keys) + else + @questions = current_user.questions.scoped({}) + @questions = @questions.created_by(params[:creator]) if params[:creator] + end + # There doesn't seem to be a good way to add procs to an array of # objects. This solution depends on Array#to_xml rendering each # member in the correct order. Internally, it just uses, #each, so -- libgit2 0.21.2