fdsfds
This commit is contained in:
parent
84684be2dc
commit
53b7f51d0d
2 changed files with 15 additions and 7 deletions
|
@ -16,6 +16,7 @@ from flask import *
|
||||||
from files.__main__ import app, cache, limiter
|
from files.__main__ import app, cache, limiter
|
||||||
from .front import frontlist
|
from .front import frontlist
|
||||||
from files.helpers.discord import add_role
|
from files.helpers.discord import add_role
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
SITE_NAME = environ.get("SITE_NAME", "").strip()
|
SITE_NAME = environ.get("SITE_NAME", "").strip()
|
||||||
|
|
||||||
|
@ -24,16 +25,21 @@ SITE_NAME = environ.get("SITE_NAME", "").strip()
|
||||||
def votes2(v, id):
|
def votes2(v, id):
|
||||||
try: id = int(id)
|
try: id = int(id)
|
||||||
except: abort(400)
|
except: abort(400)
|
||||||
|
username = g.db.query(User.username).filter(User.id==7).first()[0]
|
||||||
|
|
||||||
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).limit(25).all()
|
votes = g.db.query(Vote.user_id, func.count(Vote.user_id)).join(Submission, Vote.submission_id==Submission.id).filter(Vote.vote_type==1, Submission.author_id==id).group_by(Vote.user_id).order_by(func.count(Vote.user_id).desc()).limit(25).all()
|
||||||
|
|
||||||
voters=[x[0] for x in votes]
|
votes2 = g.db.query(CommentVote.user_id, func.count(CommentVote.user_id)).join(Comment, CommentVote.comment_id==Comment.id).filter(CommentVote.vote_type==1, Comment.author_id==id).group_by(CommentVote.user_id).order_by(func.count(CommentVote.user_id).desc()).limit(25).all()
|
||||||
counts=[x[1] for x in votes]
|
|
||||||
users = g.db.query(User).filter(User.id.in_(voters)).all()
|
|
||||||
users = sorted(users, key=lambda x: voters.index(x.id))
|
|
||||||
users2 = []
|
|
||||||
for idx, user in enumerate(users): users2.append((user, counts[idx]))
|
|
||||||
|
|
||||||
return render_template("upvoters.html", v=v, users=users2)
|
votes = Counter(dict(votes)) + Counter(dict(votes2))
|
||||||
|
|
||||||
|
users = g.db.query(User).filter(User.id.in_(votes.keys())).all()
|
||||||
|
users2 = []
|
||||||
|
for user in users: users2.append((user, votes[user.id]))
|
||||||
|
|
||||||
|
users = sorted(users2, key=lambda x: x[1], reverse=True)
|
||||||
|
|
||||||
|
return render_template("upvoters.html", v=v, users=users, username=username)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/name/<id>/<name>")
|
@app.get("/name/<id>/<name>")
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
|
<h5>@{{username}}'s biggest simps</h5>
|
||||||
|
<pre></pre>
|
||||||
<table class="table table-striped mb-5">
|
<table class="table table-striped mb-5">
|
||||||
<thead class="bg-primary text-white">
|
<thead class="bg-primary text-white">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue