diff --git a/files/routes/users.py b/files/routes/users.py index fd801b7d8..b85af7296 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -321,7 +321,16 @@ def leaderboard(v): if request.host == 'rdrama.net': users13 = topmakers else: users13 = None - return render_template(f"{template}leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6, users7=users7, users9=users9, users10=users10, users12=users12, users13=users13) + 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() + 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])) + users15 = sorted(users15, key=lambda x: x[1], reverse=True)[:25] + + + return render_template(f"{template}leaderboard.html", v=v, users1=users1, users2=users2, users3=users3, users4=users4, users5=users5, users6=users6, users7=users7, users9=users9, users10=users10, users12=users12, users13=users13, users15=users15) @app.get("/@/css") diff --git a/files/templates/leaderboard.html b/files/templates/leaderboard.html index 23955e239..970738173 100644 --- a/files/templates/leaderboard.html +++ b/files/templates/leaderboard.html @@ -304,4 +304,35 @@ {% endif %} +{% if users15 %} +
+
+
+	
+
Top 25 by upvotes given
+
+
+
+	
+ +
+ + + + + + + + + {% for user in users15 %} + + + + + + {% endfor %} + +
#NameUpvotes
{{loop.index}}@{{user[0].username}}'s profile picture{{user[0].username}}{{user[1]}}
+{% endif %} + {% endblock %} \ No newline at end of file