Move user counts to methods
This commit is contained in:
parent
7635d3a491
commit
5a9909adae
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue