mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-07 17:53:37 +01:00
Move user counts to methods
This commit is contained in:
parent
7635d3a491
commit
5a9909adae
1 changed files with 14 additions and 12 deletions
|
@ -5,18 +5,6 @@ class AboutController < ApplicationController
|
||||||
|
|
||||||
def about
|
def about
|
||||||
cache "about_counters", expires_in: 1.hour do
|
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
|
@users = user_count - current_ban_count
|
||||||
@questions = Question.count(:id)
|
@questions = Question.count(:id)
|
||||||
@answers = Answer.count(:id)
|
@answers = Answer.count(:id)
|
||||||
|
@ -28,4 +16,18 @@ class AboutController < ApplicationController
|
||||||
def privacy_policy; end
|
def privacy_policy; end
|
||||||
|
|
||||||
def terms; 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
|
end
|
||||||
|
|
Loading…
Reference in a new issue