diff --git a/files/classes/user.py b/files/classes/user.py index 196477308..7e3ff1c6d 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -372,8 +372,7 @@ class User(Base): @property @lazy def post_notifications_count(self): - return self.notifications.filter(Notification.read == False).join(Notification.comment).filter( - Comment.author_id == AUTOJANNY_ACCOUNT).count() + return self.notifications.filter(Notification.read == False).join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).count() @property @lazy diff --git a/files/routes/admin.py b/files/routes/admin.py index 679908914..8ccddd78b 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -287,7 +287,7 @@ def reported_posts(v): posts = g.db.query(Submission).options(lazyload('*')).filter_by( is_approved=0, is_banned=False - ).join(Submission.flags).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26) + ).order_by(Submission.id.desc()).offset(25 * (page - 1)).limit(26) listing = [p.id for p in posts] next_exists = (len(listing) > 25) @@ -309,7 +309,7 @@ def reported_comments(v): ).filter_by( is_approved=0, is_banned=False - ).join(Comment.flags).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all() + ).order_by(Comment.id.desc()).offset(25 * (page - 1)).limit(26).all() listing = [p.id for p in posts] next_exists = (len(listing) > 25) diff --git a/files/routes/front.py b/files/routes/front.py index 787e7eb4b..3c8fb568d 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -167,7 +167,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' posts = posts.filter(Submission.created_utc < lt) if not (v and v.shadowbanned): - posts = posts.join(Submission.author).filter(User.shadowbanned == False) + posts = posts.join(Submission.author.shadowbanned).filter(User.shadowbanned == False) if sort == "hot": ti = int(time.time()) @@ -256,7 +256,6 @@ def changeloglist(v=None, sort="new", page=1 ,t="all", **kwargs): Submission.author_id.notin_(blocked) ) - posts=posts.join(Submission.author) posts=posts.filter(Submission.title.ilike(f'_changelog%', User.admin_level == 6)) if t != 'all': diff --git a/files/routes/search.py b/files/routes/search.py index 859c87887..3d58ea64f 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -58,11 +58,7 @@ def searchposts(v): - posts = g.db.query(Submission).options( - lazyload('*') - ).join( - Submission.author - ) + posts = g.db.query(Submission).options(lazyload('*')) if not (v and v.admin_level == 6): posts = posts.filter(Submission.private == False)