Merge pull request #1089 from Retrospring/about-page-tweaks

About page tweaks
This commit is contained in:
Karina Kwiatek 2023-02-18 11:03:48 +01:00 committed by GitHub
commit 6ac2b6ca05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 20 deletions

View file

@ -4,26 +4,30 @@ class AboutController < ApplicationController
def index; end def index; end
def about def about
user_count = User cache "about_counters", expires_in: 1.hour do
.where.not(confirmed_at: nil) @users = user_count - current_ban_count
.where("answered_count > 0") @questions = Question.count(:id)
.count @answers = Answer.count(:id)
@comments = Comment.count(:id)
current_ban_count = UserBan @smiles = Appendable::Reaction.count
.current end
.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
end end
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

View file

@ -17,13 +17,13 @@
%h2= t(".statistics.header") %h2= t(".statistics.header")
%p= t(".statistics.body", app_name: APP_CONFIG["site_name"]) %p= t(".statistics.body", app_name: APP_CONFIG["site_name"])
.entry .entry
.entry__value= @questions .entry__value{ title: number_to_human(@questions) }= number_to_human @questions, units: :short, format: "%n%u"
%h4.entry__description= Question.model_name.human(count: @questions) %h4.entry__description= Question.model_name.human(count: @questions)
.entry .entry
.entry__value= @answers .entry__value{ title: number_to_human(@answers) }= number_to_human @answers, units: :short, format: "%n%u"
%h4.entry__description= Answer.model_name.human(count: @answers) %h4.entry__description= Answer.model_name.human(count: @answers)
.entry .entry
.entry__value= @users .entry__value{ title: number_to_human(@users) }= number_to_human @users, units: :short, format: "%n%u"
%h4.entry__description= User.model_name.human(count: @users) %h4.entry__description= User.model_name.human(count: @users)
= render "shared/links" = render "shared/links"

View file

@ -0,0 +1,7 @@
en:
short:
unit: ""
thousand: "K"
million: "M"
billion: "B"
trillion: "T"