From 0008acbabe8ab119e007dbe3e6b591b6013d1e2f Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Wed, 2 Nov 2022 06:50:18 +0200 Subject: [PATCH] make /stats slightly faster --- files/helpers/stats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/helpers/stats.py b/files/helpers/stats.py index ed91b6970..5362d2b23 100644 --- a/files/helpers/stats.py +++ b/files/helpers/stats.py @@ -122,8 +122,8 @@ def stats(site=None): "post voting users": g.db.query(Vote.user_id).distinct().count(), "comment votes": g.db.query(CommentVote).count(), "comment voting users": g.db.query(CommentVote.user_id).distinct().count(), - "total upvotes": g.db.query(Vote).filter_by(vote_type=1).count() + g.db.query(CommentVote.comment_id).filter_by(vote_type=1).count(), - "total downvotes": g.db.query(Vote).filter_by(vote_type=-1).count() + g.db.query(CommentVote.comment_id).filter_by(vote_type=-1).count(), + "total upvotes": g.db.query(Vote).filter_by(vote_type=1).count() + g.db.query(CommentVote).filter_by(vote_type=1).count(), + "total downvotes": g.db.query(Vote).filter_by(vote_type=-1).count() + g.db.query(CommentVote).filter_by(vote_type=-1).count(), "total awards": g.db.query(AwardRelationship).count(), "awards given": g.db.query(AwardRelationship).filter(or_(AwardRelationship.submission_id != None, AwardRelationship.comment_id != None)).count(), "users who posted, commented, or voted in the past 7 days": len(active_users),