From 139973605364113f6c9b2860af73bf3c78fd04be Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 17 Feb 2023 15:58:28 +0100 Subject: [PATCH] Cache about page --- app/controllers/about_controller.rb | 32 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb index b957e445..259f2f10 100644 --- a/app/controllers/about_controller.rb +++ b/app/controllers/about_controller.rb @@ -4,23 +4,25 @@ class AboutController < ApplicationController def index; end def about - user_count = User - .where.not(confirmed_at: nil) - .where("answered_count > 0") - .count + cache "about_counters", expires_in: 1.hour do + user_count = User + .where.not(confirmed_at: nil) + .where("answered_count > 0") + .count - current_ban_count = UserBan - .current - .joins(:user) - .where.not("users.confirmed_at": nil) - .where("users.answered_count > 0") - .count + current_ban_count = UserBan + .current + .joins(:user) + .where.not("users.confirmed_at": nil) + .where("users.answered_count > 0") + .count - @users = user_count - current_ban_count - @questions = Question.count - @answers = Answer.count - @comments = Comment.count - @smiles = Appendable::Reaction.count + @users = user_count - current_ban_count + @questions = Question.count(:id) + @answers = Answer.count(:id) + @comments = Comment.count(:id) + @smiles = Appendable::Reaction.count + end end def privacy_policy; end