From 6639f6646a01220623f3fd3f0b15b646fb66ef65 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Sun, 3 Oct 2021 20:40:25 +0200 Subject: [PATCH] only count active users on about page --- app/controllers/static_controller.rb | 11 +++++++++++ app/views/static/about.haml | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index 8854f0e4..fe888207 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -17,7 +17,18 @@ class StaticController < ApplicationController end 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 def faq diff --git a/app/views/static/about.haml b/app/views/static/about.haml index f6ad2c21..34ba6762 100644 --- a/app/views/static/about.haml +++ b/app/views/static/about.haml @@ -48,21 +48,21 @@ %p= t('views.about.statistics.desc', app_title: APP_CONFIG['site_name']) .col-md-3.col-sm-6.col-xs-6 .entry.entry--statistics - %h2.entry__value#asked-count= Question.count - %h4.entry__description= t('views.general.question').pluralize(Question.count) + %h2.entry__value#asked-count= @questions + %h4.entry__description= t('views.general.question').pluralize(@questions) .entry.entry--statistics - %h2.entry__value#answered-count= Answer.count - %h4.entry__description= t('views.general.answer').pluralize(Answer.count) + %h2.entry__value#answered-count= @answers + %h4.entry__description= t('views.general.answer').pluralize(@answers) .col-md-3.col-sm-6.col-xs-6 .entry.entry--statistics - %h2.entry__value#comment-count= Comment.count - %h4.entry__description= t('views.general.comment').pluralize(Comment.count) + %h2.entry__value#comment-count= @comments + %h4.entry__description= t('views.general.comment').pluralize(@comments) .entry.entry--statistics - %h2.entry__value#smile-count= Smile.count + CommentSmile.count - %h4.entry__description= t('views.general.smile').pluralize(Smile.count) + %h2.entry__value#smile-count= @smiles + %h4.entry__description= t('views.general.smile').pluralize(@smiles) .col-md-3.col-sm-12.col-xs-12 .entry.entry--users - .entry__value#follower-count= User.count - %h4.entry__description= t('views.general.user').pluralize(User.count) + .entry__value#follower-count= @users + %h4.entry__description= t('views.general.user').pluralize(@users) = render 'shared/links'