Class: QuestionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- QuestionsController
- Defined in:
- app/controllers/questions_controller.rb
Overview
Web controller. Provides actions that relate to questions - this is essentially the standard set of resources, plus a couple for the extra question lists (such as listing by tag).
Instance Method Summary collapse
Methods inherited from ApplicationController
#dashboard, #keyboard_tools, #upload
Instance Method Details
#lottery ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'app/controllers/questions_controller.rb', line 4 def lottery ids = Rails.cache.fetch 'lottery_questions', expires_in: 24.hours do # noinspection RailsParamDefResolve Post.main.undeleted..where(post_type: top_level_post_types) .order([Arel.sql('(RAND() - ? * DATEDIFF(CURRENT_TIMESTAMP, posts.created_at)) DESC'), SiteSetting['LotteryAgeDeprecationSpeed']]) .limit(25).select(:id).pluck(:id).to_a end @questions = Question.list_includes.where(id: ids).paginate(page: params[:page], per_page: 25) end |