diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2ba7c798a6773ce0807b8f87743d30f3a76ce815..69603f3d610d406472994180c49762a8d31b6715 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -105,9 +105,9 @@ class ApplicationController < ActionController::Base end def pull_hot_questions - @hot_questions = Rails.cache.fetch('hot_questions', expires_in: 30.minutes) do - Post.undeleted.where(updated_at: (Rails.env.development? ? 365 : 1).days.ago..Time.now) - .where(parent_id: nil).includes(:category) + @hot_questions = Rails.cache.fetch('hot_questions', expires_in: 4.hours) do + Post.undeleted.where(updated_at: (Rails.env.development? ? 365 : 7).days.ago..Time.now) + .where(post_type_id: Question.post_type_id).includes(:category) .order('score DESC').limit(SiteSetting['HotQuestionsCount']) end end diff --git a/app/views/layouts/_sidebar.html.erb b/app/views/layouts/_sidebar.html.erb index 190c879a87d1303c61400e7bea58850efcfeae66..a68343b8137addf1892d318ee299ae22f87bf5fd 100644 --- a/app/views/layouts/_sidebar.html.erb +++ b/app/views/layouts/_sidebar.html.erb @@ -12,7 +12,7 @@ <% end %> <% end %> - <% if Rails.env.development? || @hot_questions.size > 0 %> + <% if Rails.env.development? || @hot_questions.to_a.size > 0 %> <div class="widget has-margin-4"> <h4 class="widget--header has-margin-0">Hot Posts</h4> <% @hot_questions.each do |hq| %>