sdffsd
This commit is contained in:
parent
25184a2450
commit
2030d08d3e
2 changed files with 40 additions and 44 deletions
|
@ -11,13 +11,49 @@ from files.mail import *
|
|||
from flask import *
|
||||
from files.__main__ import app, limiter
|
||||
from pusher_push_notifications import PushNotifications
|
||||
from collections import Counter
|
||||
|
||||
site = environ.get("DOMAIN").strip()
|
||||
|
||||
beams_client = PushNotifications(
|
||||
instance_id=PUSHER_INSTANCE_ID,
|
||||
secret_key=PUSHER_KEY,
|
||||
)
|
||||
beams_client = PushNotifications(instance_id=PUSHER_INSTANCE_ID, secret_key=PUSHER_KEY)
|
||||
|
||||
@app.get("/@<username>/upvoters")
|
||||
@auth_desired
|
||||
def upvoters(v, username):
|
||||
id = g.db.query(User.id).filter(User.username==username).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()
|
||||
|
||||
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()
|
||||
|
||||
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, name='Up', name2='simps')
|
||||
|
||||
@app.get("/@<username>/downvoters")
|
||||
@auth_desired
|
||||
def downvoters(v, username):
|
||||
id = g.db.query(User.id).filter(User.username==username).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()
|
||||
|
||||
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()
|
||||
|
||||
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, name='Down', name2='haters')
|
||||
|
||||
@app.post("/pay_rent")
|
||||
@limiter.limit("1/second")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue