Commit 668b7e3e7054a8db81733681d0e760828528a740

Authored by Luke Baker
1 parent cbaea816

update index to not always return all questions

if votes-since is passed as a param only show those votes.  If you want
votes-since and all questions, pass all=true.
Showing 1 changed file with 8 additions and 2 deletions   Show diff stats
app/controllers/questions_controller.rb
... ... @@ -294,8 +294,6 @@ class QuestionsController < InheritedResources::Base
294 294 end
295 295  
296 296 def index
297   - @questions = current_user.questions.scoped({})
298   - @questions = @questions.created_by(params[:creator]) if params[:creator]
299 297  
300 298 counts = {}
301 299 if params[:user_ideas]
... ... @@ -314,6 +312,14 @@ class QuestionsController < InheritedResources::Base
314 312 :group => "votes.question_id")
315 313 end
316 314  
  315 + # only return questions with these recent votes
  316 + if counts['recent-votes'] && params[:all] != 'true'
  317 + @questions = current_user.questions.scoped({}).find(counts['recent-votes'].keys)
  318 + else
  319 + @questions = current_user.questions.scoped({})
  320 + @questions = @questions.created_by(params[:creator]) if params[:creator]
  321 + end
  322 +
317 323 # There doesn't seem to be a good way to add procs to an array of
318 324 # objects. This solution depends on Array#to_xml rendering each
319 325 # member in the correct order. Internally, it just uses, #each, so
... ...