add commas to stats

remotes/1693176582716663532/tmp_refs/heads/watchparty
Aevann1 2022-11-02 07:06:01 +02:00
parent 17038e31da
commit 1c536de93d
1 changed files with 35 additions and 35 deletions

View File

@ -99,45 +99,45 @@ def stats(site=None):
active_users = set(posters) | set(commenters) | set(voters) | set(commentvoters)
stats = {
"marseys": g.db.query(Marsey).filter(Marsey.submitter_id==None).count(),
"users": g.db.query(User).count(),
"private users": g.db.query(User).filter_by(is_private=True).count(),
"banned users": g.db.query(User).filter(User.is_banned > 0).count(),
"verified email users": g.db.query(User).filter_by(is_activated=True).count(),
"coins in circulation": g.db.query(func.sum(User.coins)).scalar(),
"total shop sales": g.db.query(func.sum(User.coins_spent)).scalar(),
"signups last 24h": g.db.query(User).filter(User.created_utc > day).count(),
"total posts": g.db.query(Submission).count(),
"posting users": g.db.query(Submission.author_id).distinct().count(),
"listed posts": g.db.query(Submission).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count(),
"removed posts (by admins)": g.db.query(Submission).filter_by(is_banned=True).count(),
"deleted posts (by author)": g.db.query(Submission).filter(Submission.deleted_utc > 0).count(),
"posts last 24h": g.db.query(Submission).filter(Submission.created_utc > day).count(),
"total comments": g.db.query(Comment).filter(Comment.author_id != AUTOJANNY_ID).count(),
"commenting users": g.db.query(Comment.author_id).distinct().count(),
"removed comments (by admins)": g.db.query(Comment).filter_by(is_banned=True).count(),
"deleted comments (by author)": g.db.query(Comment).filter(Comment.deleted_utc > 0).count(),
"comments last_24h": g.db.query(Comment).filter(Comment.created_utc > day, Comment.author_id != AUTOJANNY_ID).count(),
"post votes": g.db.query(Vote).count(),
"comment votes": g.db.query(CommentVote).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),
"users online in the past 7 days": g.db.query(User).filter(User.last_active > week).count(),
"marseys": "{:,}".format(g.db.query(Marsey).filter(Marsey.submitter_id==None).count()),
"users": "{:,}".format(g.db.query(User).count()),
"private users": "{:,}".format(g.db.query(User).filter_by(is_private=True).count()),
"banned users": "{:,}".format(g.db.query(User).filter(User.is_banned > 0).count()),
"verified email users": "{:,}".format(g.db.query(User).filter_by(is_activated=True).count()),
"coins in circulation": "{:,}".format(g.db.query(func.sum(User.coins)).scalar()),
"total shop sales": "{:,}".format(g.db.query(func.sum(User.coins_spent)).scalar()),
"signups last 24h": "{:,}".format(g.db.query(User).filter(User.created_utc > day).count()),
"total posts": "{:,}".format(g.db.query(Submission).count()),
"posting users": "{:,}".format(g.db.query(Submission.author_id).distinct().count()),
"listed posts": "{:,}".format(g.db.query(Submission).filter_by(is_banned=False).filter(Submission.deleted_utc == 0).count()),
"removed posts (by admins)": "{:,}".format(g.db.query(Submission).filter_by(is_banned=True).count()),
"deleted posts (by author)": "{:,}".format(g.db.query(Submission).filter(Submission.deleted_utc > 0).count()),
"posts last 24h": "{:,}".format(g.db.query(Submission).filter(Submission.created_utc > day).count()),
"total comments": "{:,}".format(g.db.query(Comment).filter(Comment.author_id != AUTOJANNY_ID).count()),
"commenting users": "{:,}".format(g.db.query(Comment.author_id).distinct().count()),
"removed comments (by admins)": "{:,}".format(g.db.query(Comment).filter_by(is_banned=True).count()),
"deleted comments (by author)": "{:,}".format(g.db.query(Comment).filter(Comment.deleted_utc > 0).count()),
"comments last_24h": "{:,}".format(g.db.query(Comment).filter(Comment.created_utc > day, Comment.author_id != AUTOJANNY_ID).count()),
"post votes": "{:,}".format(g.db.query(Vote).count()),
"comment votes": "{:,}".format(g.db.query(CommentVote).count()),
"total upvotes": "{:,}".format(g.db.query(Vote).filter_by(vote_type=1).count() + g.db.query(CommentVote).filter_by(vote_type=1).count()),
"total downvotes": "{:,}".format(g.db.query(Vote).filter_by(vote_type=-1).count() + g.db.query(CommentVote).filter_by(vote_type=-1).count()),
"total awards": "{:,}".format(g.db.query(AwardRelationship).count()),
"awards given": "{:,}".format(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": "{:,}".format(len(active_users)),
"users online in the past 7 days": "{:,}".format(g.db.query(User).filter(User.last_active > week).count()),
}
if SITE_NAME == 'rDrama' or FEATURES['HOUSES']:
stats2 = {
"House furry members": g.db.query(User).filter(User.house.like('Furry%')).count(),
"House femboy members": g.db.query(User).filter(User.house.like('Femboy%')).count(),
"House vampire members": g.db.query(User).filter(User.house.like('Vampire%')).count(),
"House racist members": g.db.query(User).filter(User.house.like('Racist%')).count(),
"House furry total truescore": g.db.query(func.sum(User.truecoins)).filter(User.house.like('Furry%')).scalar(),
"House femboy total truescore": g.db.query(func.sum(User.truecoins)).filter(User.house.like('Femboy%')).scalar(),
"House vampire total truescore": g.db.query(func.sum(User.truecoins)).filter(User.house.like('Vampire%')).scalar(),
"House racist total truescore": g.db.query(func.sum(User.truecoins)).filter(User.house.like('Racist%')).scalar(),
"House furry members": "{:,}".format(g.db.query(User).filter(User.house.like('Furry%')).count()),
"House femboy members": "{:,}".format(g.db.query(User).filter(User.house.like('Femboy%')).count()),
"House vampire members": "{:,}".format(g.db.query(User).filter(User.house.like('Vampire%')).count()),
"House racist members": "{:,}".format(g.db.query(User).filter(User.house.like('Racist%')).count()),
"House furry total truescore": "{:,}".format(g.db.query(func.sum(User.truecoins)).filter(User.house.like('Furry%')).scalar() or 0),
"House femboy total truescore": "{:,}".format(g.db.query(func.sum(User.truecoins)).filter(User.house.like('Femboy%')).scalar() or 0),
"House vampire total truescore": "{:,}".format(g.db.query(func.sum(User.truecoins)).filter(User.house.like('Vampire%')).scalar() or 0),
"House racist total truescore": "{:,}".format(g.db.query(func.sum(User.truecoins)).filter(User.house.like('Racist%')).scalar() or 0),
}
stats.update(stats2)