forked from MarseyWorld/MarseyWorld
fds
parent
7ecd8f1cfd
commit
7f06386cc3
|
@ -390,11 +390,8 @@ def random_post(v):
|
|||
@cache.memoize(timeout=86400)
|
||||
def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"):
|
||||
|
||||
posts = g.db.query(Submission)
|
||||
cc_idlist = [x[0] for x in g.db.query(Submission.id).filter(Submission.club == True).all()]
|
||||
|
||||
posts = posts.subquery()
|
||||
|
||||
comments = g.db.query(Comment.id).filter(Comment.parent_submission.notin_(cc_idlist))
|
||||
|
||||
if v and v.admin_level <= 3:
|
||||
|
|
|
@ -320,55 +320,41 @@ def transfer_bux(v, username):
|
|||
def leaderboard(v):
|
||||
users = g.db.query(User)
|
||||
|
||||
|
||||
# Assuming you have a session established somewhere
|
||||
# though `MoviePersonScores.query` may work just the same
|
||||
|
||||
query = g.db.query(
|
||||
User,
|
||||
func.rank()\
|
||||
.over(
|
||||
order_by=User.coins
|
||||
)\
|
||||
.label('rank')
|
||||
)
|
||||
|
||||
# now filter
|
||||
query = query.filter_by(id=v.id)
|
||||
|
||||
# Or, just get the first value
|
||||
my_movie = query.first()
|
||||
|
||||
print(my_movie)
|
||||
|
||||
|
||||
users1 = users.order_by(User.coins.desc()).limit(25).all()
|
||||
pos1 = g.db.query(User, func.rank().over(order_by=User.coins.desc())).filter_by(id=v.id).first()[1]
|
||||
sq = g.db.query(User.id, func.rank().over(order_by=User.coins.desc()).label("rank")).subquery()
|
||||
pos1 = g.db.query(sq.c.id, sq.c.rank).filter(sq.c.id == v.id).limit(1).one()[1]
|
||||
|
||||
users2 = users.order_by(User.stored_subscriber_count.desc()).limit(25).all()
|
||||
pos2 = g.db.query(User, func.rank().over(order_by=User.stored_subscriber_count.desc())).filter_by(id=v.id).first()[1]
|
||||
users2 = users.order_by(User.stored_subscriber_count.desc()).all()
|
||||
pos2 = users2.index(v)
|
||||
users2 = users2[:25]
|
||||
|
||||
users3 = users.order_by(User.post_count.desc()).limit(25).all()
|
||||
pos3 = g.db.query(User, func.rank().over(order_by=User.post_count.desc())).filter_by(id=v.id).first()[1]
|
||||
users3 = users.order_by(User.post_count.desc()).all()
|
||||
pos3 = users3.index(v)
|
||||
users3 = users3[:25]
|
||||
|
||||
users4 = users.order_by(User.comment_count.desc()).limit(25).all()
|
||||
pos4 = g.db.query(User, func.rank().over(order_by=User.comment_count.desc())).filter_by(id=v.id).first()[1]
|
||||
users4 = users.order_by(User.comment_count.desc()).all()
|
||||
pos4 = users4.index(v)
|
||||
users4 = users4[:25]
|
||||
|
||||
users5 = users.order_by(User.received_award_count.desc()).limit(25).all()
|
||||
pos5 = g.db.query(User, func.rank().over(order_by=User.received_award_count.desc())).filter_by(id=v.id).first()[1]
|
||||
users5 = users.order_by(User.received_award_count.desc()).all()
|
||||
pos5 = users5.index(v)
|
||||
users5 = users5[:25]
|
||||
|
||||
if request.host == 'pcmemes.net':
|
||||
users6 = users.order_by(User.basedcount.desc()).limit(25).all()
|
||||
pos6 = g.db.query(User, func.rank().over(order_by=User.basedcount.desc())).filter_by(id=v.id).first()[1]
|
||||
users6 = users.order_by(User.basedcount.desc()).all()
|
||||
pos6 = users6.index(v)
|
||||
users6 = users6[:25]
|
||||
else:
|
||||
users6 = None
|
||||
pos6 = None
|
||||
|
||||
users7 = users.order_by(User.coins_spent.desc()).limit(25).all()
|
||||
pos7 = g.db.query(User, func.rank().over(order_by=User.coins_spent.desc())).filter_by(id=v.id).first()[1]
|
||||
users7 = users.order_by(User.coins_spent.desc()).all()
|
||||
pos7 = users7.index(v)
|
||||
users7 = users7[:25]
|
||||
|
||||
users10 = users.order_by(User.truecoins.desc()).limit(25).all()
|
||||
pos10 = g.db.query(User, func.rank().over(order_by=User.coins_spent.desc())).filter_by(id=v.id).first()[1]
|
||||
users10 = users.order_by(User.truecoins.desc()).all()
|
||||
pos10 = users10.index(v)
|
||||
users10 = users10[:25]
|
||||
|
||||
return render_template("leaderboard.html", v=v, users1=users1, pos1=pos1, users2=users2, pos2=pos2, users3=users3, pos3=pos3, users4=users4, pos4=pos4, users5=users5, pos5=pos5, users6=users6, pos6=pos6, users7=users7, pos7=pos7, users9=users9, users10=users10, pos10=pos10, users12=users12, users13=users13, users15=users15)
|
||||
|
||||
|
|
Loading…
Reference in New Issue