Move user counts to methods

This commit is contained in:
Karina Kwiatek 2023-02-18 10:55:35 +01:00
parent 7635d3a491
commit 5a9909adae
1 changed files with 14 additions and 12 deletions

View File

@ -5,18 +5,6 @@ class AboutController < ApplicationController
def about
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
@users = user_count - current_ban_count
@questions = Question.count(:id)
@answers = Answer.count(:id)
@ -28,4 +16,18 @@ class AboutController < ApplicationController
def privacy_policy; end
def terms; end
private
def user_count = User
.where.not(confirmed_at: nil)
.where("answered_count > 0")
.count
def current_ban_count = UserBan
.current
.joins(:user)
.where.not("users.confirmed_at": nil)
.where("users.answered_count > 0")
.count
end