forked from rDrama/rDrama
fse
parent
96f11d941b
commit
df7dd13c61
|
@ -360,7 +360,7 @@ class User(Base):
|
|||
data = g.db.query(
|
||||
User,
|
||||
aliased(Alt, alias=subq)
|
||||
).join(
|
||||
).options(lazyload('*')).join(
|
||||
subq,
|
||||
or_(
|
||||
subq.c.user1 == User.id,
|
||||
|
@ -489,10 +489,10 @@ class User(Base):
|
|||
|
||||
if self.admin_level == 0:
|
||||
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()]
|
||||
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()]
|
||||
|
||||
posts = posts.filter(
|
||||
|
@ -513,10 +513,10 @@ class User(Base):
|
|||
|
||||
if self.admin_level == 0:
|
||||
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()]
|
||||
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()]
|
||||
|
||||
comments = comments.filter(
|
||||
|
|
|
@ -9,7 +9,7 @@ def get_user(username, v=None, graceful=False):
|
|||
|
||||
user = g.db.query(
|
||||
User
|
||||
).filter(
|
||||
).options(lazyload('*')).filter(
|
||||
or_(
|
||||
User.username.ilike(username),
|
||||
User.original_username.ilike(username)
|
||||
|
@ -80,7 +80,7 @@ def get_post(i, v=None, graceful=False):
|
|||
Submission,
|
||||
vt.c.vote_type,
|
||||
blocking.c.id,
|
||||
)
|
||||
).options(lazyload('*'))
|
||||
|
||||
items=items.filter(Submission.id == i
|
||||
).join(
|
||||
|
@ -103,7 +103,7 @@ def get_post(i, v=None, graceful=False):
|
|||
else:
|
||||
items = g.db.query(
|
||||
Submission
|
||||
).filter(Submission.id == i).first()
|
||||
).options(lazyload('*')).filter(Submission.id == i).first()
|
||||
if not items and not graceful:
|
||||
abort(404)
|
||||
x=items
|
||||
|
@ -132,7 +132,7 @@ def get_posts(pids, v=None):
|
|||
vt.c.vote_type,
|
||||
blocking.c.id,
|
||||
blocked.c.id,
|
||||
).filter(
|
||||
).options(lazyload('*')).filter(
|
||||
Submission.id.in_(pids)
|
||||
).join(
|
||||
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,
|
||||
blocking.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):
|
||||
shadowbanned = [x[0] for x in g.db.query(User.id).options(lazyload('*')).filter(User.shadowbanned != None).all()]
|
||||
|
|
|
@ -284,7 +284,7 @@ def reported_comments(v):
|
|||
page = max(1, int(request.values.get("page", 1)))
|
||||
|
||||
posts = g.db.query(Comment
|
||||
).filter_by(
|
||||
).options(lazyload('*')).filter_by(
|
||||
is_approved=0,
|
||||
is_banned=False
|
||||
).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)
|
||||
|
||||
u1_post_ups = g.db.query(
|
||||
Vote.submission_id).filter_by(
|
||||
Vote.submission_id).options(lazyload('*')).filter_by(
|
||||
user_id=u1.id,
|
||||
vote_type=1).all()
|
||||
u1_post_downs = g.db.query(
|
||||
Vote.submission_id).filter_by(
|
||||
Vote.submission_id).options(lazyload('*')).filter_by(
|
||||
user_id=u1.id,
|
||||
vote_type=-1).all()
|
||||
u1_comment_ups = g.db.query(
|
||||
CommentVote.comment_id).filter_by(
|
||||
CommentVote.comment_id).options(lazyload('*')).filter_by(
|
||||
user_id=u1.id,
|
||||
vote_type=1).all()
|
||||
u1_comment_downs = g.db.query(
|
||||
CommentVote.comment_id).filter_by(
|
||||
CommentVote.comment_id).options(lazyload('*')).filter_by(
|
||||
user_id=u1.id,
|
||||
vote_type=-1).all()
|
||||
u2_post_ups = g.db.query(
|
||||
Vote.submission_id).filter_by(
|
||||
Vote.submission_id).options(lazyload('*')).filter_by(
|
||||
user_id=u2.id,
|
||||
vote_type=1).all()
|
||||
u2_post_downs = g.db.query(
|
||||
Vote.submission_id).filter_by(
|
||||
Vote.submission_id).options(lazyload('*')).filter_by(
|
||||
user_id=u2.id,
|
||||
vote_type=-1).all()
|
||||
u2_comment_ups = g.db.query(
|
||||
CommentVote.comment_id).filter_by(
|
||||
CommentVote.comment_id).options(lazyload('*')).filter_by(
|
||||
user_id=u2.id,
|
||||
vote_type=1).all()
|
||||
u2_comment_downs = g.db.query(
|
||||
CommentVote.comment_id).filter_by(
|
||||
CommentVote.comment_id).options(lazyload('*')).filter_by(
|
||||
user_id=u2.id,
|
||||
vote_type=-1).all()
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None):
|
|||
votes.c.vote_type,
|
||||
blocking.c.id,
|
||||
blocked.c.id,
|
||||
)
|
||||
).options(lazyload('*'))
|
||||
|
||||
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()]
|
||||
|
|
|
@ -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:
|
||||
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()]
|
||||
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()]
|
||||
posts = posts.filter(
|
||||
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:
|
||||
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()]
|
||||
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()]
|
||||
posts = posts.filter(
|
||||
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:
|
||||
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()]
|
||||
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()]
|
||||
|
||||
comments = comments.filter(
|
||||
|
|
|
@ -280,7 +280,7 @@ def sign_up_post(v):
|
|||
return redirect(existing_account.url)
|
||||
|
||||
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(
|
||||
"An account with that username or email already exists.")
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ def post_id(pid, anything=None, v=None):
|
|||
votes.c.vote_type,
|
||||
blocking.c.id,
|
||||
blocked.c.id,
|
||||
)
|
||||
).options(lazyload('*'))
|
||||
|
||||
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()]
|
||||
|
|
|
@ -100,10 +100,10 @@ def searchposts(v):
|
|||
pass
|
||||
elif v:
|
||||
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()]
|
||||
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()]
|
||||
|
||||
posts = posts.filter(
|
||||
|
|
|
@ -141,7 +141,7 @@ def patrons(v):
|
|||
query = g.db.query(
|
||||
User.id, User.username, User.patron, User.namecolor,
|
||||
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) \
|
||||
.order_by(User.patron.desc(), AwardRelationship.kind.desc()) \
|
||||
.join(User).all()
|
||||
|
|
Loading…
Reference in New Issue