only count active users on about page

This commit is contained in:
Andreas Nedbal 2021-10-03 20:40:25 +02:00
parent adf9301971
commit 6639f6646a
2 changed files with 21 additions and 10 deletions

View File

@ -17,7 +17,18 @@ class StaticController < ApplicationController
end end
def about def about
@users = User
.where('confirmed_at IS NOT NULL')
.where(permanently_banned: false)
.where(banned_until: nil)
.where('answered_count > 0')
.where('asked_count > 0')
.count
@questions = Question.count
@answers = Answer.count
@comments = Comment.count
@smiles = Smile.count + CommentSmile.count
end end
def faq def faq

View File

@ -48,21 +48,21 @@
%p= t('views.about.statistics.desc', app_title: APP_CONFIG['site_name']) %p= t('views.about.statistics.desc', app_title: APP_CONFIG['site_name'])
.col-md-3.col-sm-6.col-xs-6 .col-md-3.col-sm-6.col-xs-6
.entry.entry--statistics .entry.entry--statistics
%h2.entry__value#asked-count= Question.count %h2.entry__value#asked-count= @questions
%h4.entry__description= t('views.general.question').pluralize(Question.count) %h4.entry__description= t('views.general.question').pluralize(@questions)
.entry.entry--statistics .entry.entry--statistics
%h2.entry__value#answered-count= Answer.count %h2.entry__value#answered-count= @answers
%h4.entry__description= t('views.general.answer').pluralize(Answer.count) %h4.entry__description= t('views.general.answer').pluralize(@answers)
.col-md-3.col-sm-6.col-xs-6 .col-md-3.col-sm-6.col-xs-6
.entry.entry--statistics .entry.entry--statistics
%h2.entry__value#comment-count= Comment.count %h2.entry__value#comment-count= @comments
%h4.entry__description= t('views.general.comment').pluralize(Comment.count) %h4.entry__description= t('views.general.comment').pluralize(@comments)
.entry.entry--statistics .entry.entry--statistics
%h2.entry__value#smile-count= Smile.count + CommentSmile.count %h2.entry__value#smile-count= @smiles
%h4.entry__description= t('views.general.smile').pluralize(Smile.count) %h4.entry__description= t('views.general.smile').pluralize(@smiles)
.col-md-3.col-sm-12.col-xs-12 .col-md-3.col-sm-12.col-xs-12
.entry.entry--users .entry.entry--users
.entry__value#follower-count= User.count .entry__value#follower-count= @users
%h4.entry__description= t('views.general.user').pluralize(User.count) %h4.entry__description= t('views.general.user').pluralize(@users)
= render 'shared/links' = render 'shared/links'