remove time measurements, sort awards

master
atrc445 2021-08-28 14:58:59 +02:00
parent 7fab1287cc
commit eef02d358a
1 changed files with 3 additions and 7 deletions

View File

@ -45,14 +45,12 @@ def participation_stats(v):
@app.get("/paypigs") @app.get("/paypigs")
@auth_desired @auth_desired
def patrons(v): def patrons(v):
import time
s = time.time()
query = g.db.query( query = g.db.query(
User.id, User.username, User.patron, User.namecolor, User.id, User.username, User.patron, User.namecolor,
AwardRelationship.kind.label('last_award_kind'), func.count(AwardRelationship.id).label('last_award_count') AwardRelationship.kind.label('last_award_kind'), func.count(AwardRelationship.id).label('last_award_count')
).filter(AwardRelationship.submission_id==None, AwardRelationship.comment_id==None) \ ).filter(AwardRelationship.submission_id==None, AwardRelationship.comment_id==None, User.patron > 0) \
.group_by(User.username, User.patron, User.id, User.namecolor, AwardRelationship.kind) \ .group_by(User.username, User.patron, User.id, User.namecolor, AwardRelationship.kind) \
.order_by(User.patron.desc(), AwardRelationship.kind.asc()) \ .order_by(User.patron.desc(), AwardRelationship.kind.desc()) \
.join(User).all() .join(User).all()
result = {} result = {}
@ -66,9 +64,7 @@ def patrons(v):
if kind in AWARDS.keys(): if kind in AWARDS.keys():
result[user_id]['awards'][kind] = (AWARDS[kind], row['last_award_count']) result[user_id]['awards'][kind] = (AWARDS[kind], row['last_award_count'])
r = render_template("patrons.html", v=v, result=result) return render_template("patrons.html", v=v, result=result)
print((time.time()-s)*1000, flush=True)
return r
@app.get("/admins") @app.get("/admins")
@auth_desired @auth_desired