remotes/1693045480750635534/spooky-22
Aevann1 2021-11-02 13:54:04 -07:00
parent 96f11d941b
commit df7dd13c61
9 changed files with 31 additions and 31 deletions

View File

@ -360,7 +360,7 @@ class User(Base):
data = g.db.query( data = g.db.query(
User, User,
aliased(Alt, alias=subq) aliased(Alt, alias=subq)
).join( ).options(lazyload('*')).join(
subq, subq,
or_( or_(
subq.c.user1 == User.id, subq.c.user1 == User.id,
@ -489,10 +489,10 @@ class User(Base):
if self.admin_level == 0: if self.admin_level == 0:
blocking = [x[0] for x in g.db.query( blocking = [x[0] for x in g.db.query(
UserBlock.target_id).filter_by( UserBlock.target_id).options(lazyload('*')).filter_by(
user_id=self.id).all()] user_id=self.id).all()]
blocked = [x[0] for x in g.db.query( blocked = [x[0] for x in g.db.query(
UserBlock.user_id).filter_by( UserBlock.user_id).options(lazyload('*')).filter_by(
target_id=self.id).all()] target_id=self.id).all()]
posts = posts.filter( posts = posts.filter(
@ -513,10 +513,10 @@ class User(Base):
if self.admin_level == 0: if self.admin_level == 0:
blocking = [x[0] for x in g.db.query( blocking = [x[0] for x in g.db.query(
UserBlock.target_id).filter_by( UserBlock.target_id).options(lazyload('*')).filter_by(
user_id=self.id).all()] user_id=self.id).all()]
blocked = [x[0] for x in g.db.query( blocked = [x[0] for x in g.db.query(
UserBlock.user_id).filter_by( UserBlock.user_id).options(lazyload('*')).filter_by(
target_id=self.id).all()] target_id=self.id).all()]
comments = comments.filter( comments = comments.filter(

View File

@ -9,7 +9,7 @@ def get_user(username, v=None, graceful=False):
user = g.db.query( user = g.db.query(
User User
).filter( ).options(lazyload('*')).filter(
or_( or_(
User.username.ilike(username), User.username.ilike(username),
User.original_username.ilike(username) User.original_username.ilike(username)
@ -80,7 +80,7 @@ def get_post(i, v=None, graceful=False):
Submission, Submission,
vt.c.vote_type, vt.c.vote_type,
blocking.c.id, blocking.c.id,
) ).options(lazyload('*'))
items=items.filter(Submission.id == i items=items.filter(Submission.id == i
).join( ).join(
@ -103,7 +103,7 @@ def get_post(i, v=None, graceful=False):
else: else:
items = g.db.query( items = g.db.query(
Submission Submission
).filter(Submission.id == i).first() ).options(lazyload('*')).filter(Submission.id == i).first()
if not items and not graceful: if not items and not graceful:
abort(404) abort(404)
x=items x=items
@ -132,7 +132,7 @@ def get_posts(pids, v=None):
vt.c.vote_type, vt.c.vote_type,
blocking.c.id, blocking.c.id,
blocked.c.id, blocked.c.id,
).filter( ).options(lazyload('*')).filter(
Submission.id.in_(pids) Submission.id.in_(pids)
).join( ).join(
vt, vt.c.submission_id==Submission.id, isouter=True vt, vt.c.submission_id==Submission.id, isouter=True
@ -207,7 +207,7 @@ def get_comments(cids, v=None, load_parent=False):
votes.c.vote_type, votes.c.vote_type,
blocking.c.id, blocking.c.id,
blocked.c.id, blocked.c.id,
).filter(Comment.id.in_(cids)) ).options(lazyload('*')).filter(Comment.id.in_(cids))
if not (v and v.shadowbanned) and not (v and v.admin_level == 6): if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()]

View File

@ -284,7 +284,7 @@ def reported_comments(v):
page = max(1, int(request.values.get("page", 1))) page = max(1, int(request.values.get("page", 1)))
posts = g.db.query(Comment posts = g.db.query(Comment
).filter_by( ).options(lazyload('*')).filter_by(
is_approved=0, is_approved=0,
is_banned=False is_banned=False
).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all() ).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all()
@ -428,35 +428,35 @@ def alt_votes_get(v):
u2 = get_user(u2) u2 = get_user(u2)
u1_post_ups = g.db.query( u1_post_ups = g.db.query(
Vote.submission_id).filter_by( Vote.submission_id).options(lazyload('*')).filter_by(
user_id=u1.id, user_id=u1.id,
vote_type=1).all() vote_type=1).all()
u1_post_downs = g.db.query( u1_post_downs = g.db.query(
Vote.submission_id).filter_by( Vote.submission_id).options(lazyload('*')).filter_by(
user_id=u1.id, user_id=u1.id,
vote_type=-1).all() vote_type=-1).all()
u1_comment_ups = g.db.query( u1_comment_ups = g.db.query(
CommentVote.comment_id).filter_by( CommentVote.comment_id).options(lazyload('*')).filter_by(
user_id=u1.id, user_id=u1.id,
vote_type=1).all() vote_type=1).all()
u1_comment_downs = g.db.query( u1_comment_downs = g.db.query(
CommentVote.comment_id).filter_by( CommentVote.comment_id).options(lazyload('*')).filter_by(
user_id=u1.id, user_id=u1.id,
vote_type=-1).all() vote_type=-1).all()
u2_post_ups = g.db.query( u2_post_ups = g.db.query(
Vote.submission_id).filter_by( Vote.submission_id).options(lazyload('*')).filter_by(
user_id=u2.id, user_id=u2.id,
vote_type=1).all() vote_type=1).all()
u2_post_downs = g.db.query( u2_post_downs = g.db.query(
Vote.submission_id).filter_by( Vote.submission_id).options(lazyload('*')).filter_by(
user_id=u2.id, user_id=u2.id,
vote_type=-1).all() vote_type=-1).all()
u2_comment_ups = g.db.query( u2_comment_ups = g.db.query(
CommentVote.comment_id).filter_by( CommentVote.comment_id).options(lazyload('*')).filter_by(
user_id=u2.id, user_id=u2.id,
vote_type=1).all() vote_type=1).all()
u2_comment_downs = g.db.query( u2_comment_downs = g.db.query(
CommentVote.comment_id).filter_by( CommentVote.comment_id).options(lazyload('*')).filter_by(
user_id=u2.id, user_id=u2.id,
vote_type=-1).all() vote_type=-1).all()

View File

@ -88,7 +88,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
votes.c.vote_type, votes.c.vote_type,
blocking.c.id, blocking.c.id,
blocked.c.id, blocked.c.id,
) ).options(lazyload('*'))
if not (v and v.shadowbanned) and not (v and v.admin_level == 6): if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()]

View File

@ -164,10 +164,10 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words='
if v and v.admin_level == 0: if v and v.admin_level == 0:
blocking = [x[0] for x in g.db.query( blocking = [x[0] for x in g.db.query(
UserBlock.target_id).filter_by( UserBlock.target_id).options(lazyload('*')).filter_by(
user_id=v.id).all()] user_id=v.id).all()]
blocked = [x[0] for x in g.db.query( blocked = [x[0] for x in g.db.query(
UserBlock.user_id).filter_by( UserBlock.user_id).options(lazyload('*')).filter_by(
target_id=v.id).all()] target_id=v.id).all()]
posts = posts.filter( posts = posts.filter(
Submission.author_id.notin_(blocking), Submission.author_id.notin_(blocking),
@ -260,10 +260,10 @@ def changeloglist(v=None, sort="new", page=1 ,t="all"):
if v and v.admin_level == 0: if v and v.admin_level == 0:
blocking = [x[0] for x in g.db.query( blocking = [x[0] for x in g.db.query(
UserBlock.target_id).filter_by( UserBlock.target_id).options(lazyload('*')).filter_by(
user_id=v.id).all()] user_id=v.id).all()]
blocked = [x[0] for x in g.db.query( blocked = [x[0] for x in g.db.query(
UserBlock.user_id).filter_by( UserBlock.user_id).options(lazyload('*')).filter_by(
target_id=v.id).all()] target_id=v.id).all()]
posts = posts.filter( posts = posts.filter(
Submission.author_id.notin_(blocking), Submission.author_id.notin_(blocking),
@ -329,10 +329,10 @@ def comment_idlist(page=1, v=None, nsfw=False, sort="new", t="all"):
if v and v.admin_level <= 3: if v and v.admin_level <= 3:
blocking = [x[0] for x in g.db.query( blocking = [x[0] for x in g.db.query(
UserBlock.target_id).filter_by( UserBlock.target_id).options(lazyload('*')).filter_by(
user_id=v.id).all()] user_id=v.id).all()]
blocked = [x[0] for x in g.db.query( blocked = [x[0] for x in g.db.query(
UserBlock.user_id).filter_by( UserBlock.user_id).options(lazyload('*')).filter_by(
target_id=v.id).all()] target_id=v.id).all()]
comments = comments.filter( comments = comments.filter(

View File

@ -280,7 +280,7 @@ def sign_up_post(v):
return redirect(existing_account.url) return redirect(existing_account.url)
if existing_account or (email and g.db.query( if existing_account or (email and g.db.query(
User).filter(User.email.ilike(email)).first()): User).options(lazyload('*')).filter(User.email.ilike(email)).first()):
return new_signup( return new_signup(
"An account with that username or email already exists.") "An account with that username or email already exists.")

View File

@ -126,7 +126,7 @@ def post_id(pid, anything=None, v=None):
votes.c.vote_type, votes.c.vote_type,
blocking.c.id, blocking.c.id,
blocked.c.id, blocked.c.id,
) ).options(lazyload('*'))
if not (v and v.shadowbanned) and not (v and v.admin_level == 6): if not (v and v.shadowbanned) and not (v and v.admin_level == 6):
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()] shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()]

View File

@ -100,10 +100,10 @@ def searchposts(v):
pass pass
elif v: elif v:
blocking = [x[0] for x in g.db.query( blocking = [x[0] for x in g.db.query(
UserBlock.target_id).filter_by( UserBlock.target_id).options(lazyload('*')).filter_by(
user_id=v.id).all()] user_id=v.id).all()]
blocked = [x[0] for x in g.db.query( blocked = [x[0] for x in g.db.query(
UserBlock.user_id).filter_by( UserBlock.user_id).options(lazyload('*')).filter_by(
target_id=v.id).all()] target_id=v.id).all()]
posts = posts.filter( posts = posts.filter(

View File

@ -141,7 +141,7 @@ def patrons(v):
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, User.patron > 0) \ ).options(lazyload('*')).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.desc()) \ .order_by(User.patron.desc(), AwardRelationship.kind.desc()) \
.join(User).all() .join(User).all()