forked from rDrama/rDrama
Fix /stats distinct user count fields.
The COUNT(*) performance optimization in b71ae6cc74
was a bit
overzealous and wound up breaking four fields in /stats intended to
count distinct users who performed certain activities. These fields
were returned to their original implementation.
master
parent
f71b5dced4
commit
32416e71fa
|
@ -95,20 +95,20 @@ def stats(site=None):
|
||||||
"total shop sales": g.db.query(func.sum(User.coins_spent)).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(),
|
"signups last 24h": g.db.query(User).filter(User.created_utc > day).count(),
|
||||||
"total posts": g.db.query(Submission).count(),
|
"total posts": g.db.query(Submission).count(),
|
||||||
"posting users": g.db.query(Submission).distinct().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(),
|
"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(),
|
"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(),
|
"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(),
|
"posts last 24h": g.db.query(Submission).filter(Submission.created_utc > day).count(),
|
||||||
"total comments": g.db.query(Comment).filter(Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
"total comments": g.db.query(Comment).filter(Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
||||||
"commenting users": g.db.query(Comment).distinct().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(),
|
"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(),
|
"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.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
"comments last_24h": g.db.query(Comment).filter(Comment.created_utc > day, Comment.author_id.notin_((AUTOJANNY_ID,NOTIFICATIONS_ID))).count(),
|
||||||
"post votes": g.db.query(Vote).count(),
|
"post votes": g.db.query(Vote).count(),
|
||||||
"post voting users": g.db.query(Vote).distinct().count(),
|
"post voting users": g.db.query(Vote.user_id).distinct().count(),
|
||||||
"comment votes": g.db.query(CommentVote).count(),
|
"comment votes": g.db.query(CommentVote).count(),
|
||||||
"comment voting users": g.db.query(CommentVote).distinct().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 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 downvotes": g.db.query(Vote).filter_by(vote_type=-1).count() + g.db.query(CommentVote.comment_id).filter_by(vote_type=-1).count(),
|
||||||
"total awards": g.db.query(AwardRelationship).count(),
|
"total awards": g.db.query(AwardRelationship).count(),
|
||||||
|
|
Loading…
Reference in New Issue