Merge pull request #1096 from Retrospring/fix/abour-counter-caching

Fix caching of counters on about page
This commit is contained in:
Karina Kwiatek 2023-02-19 18:35:33 +01:00 committed by GitHub
commit 20e242d359
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -4,12 +4,10 @@ class AboutController < ApplicationController
def index; end
def about
cache "about_counters", expires_in: 1.hour do
@users = user_count - current_ban_count
@questions = Question.count(:id)
@answers = Answer.count(:id)
@comments = Comment.count(:id)
end
@users = Rails.cache.fetch "about_count_users", expires_in: 1.hour { user_count - current_ban_count }
@questions = Rails.cache.fetch "about_count_questions", expires_in: 1.hour { Question.count(:id) }
@answers = Rails.cache.fetch "about_count_answers", expires_in: 1.hour { Answer.count(:id) }
@comments = Rails.cache.fetch "about_count_comments", expires_in: 1.hour { Comment.count(:id) }
end
def privacy_policy; end