master
Aevann1 2022-01-11 06:39:28 +02:00
parent de00510fca
commit 7f61d1808b
1 changed files with 3 additions and 2 deletions

View File

@ -322,11 +322,12 @@ def leaderboard(v):
else: users13 = None
votes1 = g.db.query(Vote.user_id, func.count(Vote.user_id)).filter(Vote.vote_type==1).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).all()
votes1 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).filter(CommentVote.vote_type==1).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).filter(CommentVote.vote_type==1).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).all()
votes3 = Counter(dict(votes1)) + Counter(dict(votes2))
users14 = g.db.query(User).filter(User.id.in_(votes3.keys())).all()
users15 = []
for user in users14: users15.append((user, votes3[user.id]))
for user in users14:
users15.append((user, votes3[user.id]-user.post_count-user.comment_count))
users15 = sorted(users15, key=lambda x: x[1], reverse=True)[:25]