Cache about page

This commit is contained in:
Karina Kwiatek 2023-02-17 15:58:28 +01:00
parent 2de6ed9bf9
commit 1399736053
1 changed files with 17 additions and 15 deletions

View File

@ -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