diff --git a/files/routes/posts.py b/files/routes/posts.py index d4484a05a..f62cd7a96 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -179,7 +179,7 @@ def post_id(pid, anything=None, v=None): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - first = [c[0] for c in comments.filter(Comment.slots_result == None, Comment.blackjack_result == None, func.length(Comment.body) > 20).all()] + first = [c[0] for c in comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None), func.length(Comment.body) > 20)).all()] second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None), func.length(Comment.body) <= 20).all()] comments = first + second else: @@ -198,7 +198,7 @@ def post_id(pid, anything=None, v=None): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - first = comments.filter(Comment.slots_result == None, Comment.blackjack_result == None, func.length(Comment.body) > 20).all() + first = comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None), func.length(Comment.body) > 20)).all() second = comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None), func.length(Comment.body) <= 20).all() comments = first + second @@ -302,7 +302,7 @@ def viewmore(v, pid, sort, offset): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - first = [c[0] for c in comments.filter(Comment.slots_result == None, Comment.blackjack_result == None, func.length(Comment.body) > 20).all()] + first = [c[0] for c in comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None), func.length(Comment.body) > 20)).all()] second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None), func.length(Comment.body) <= 20).all()] comments = first + second comments = comments[offset:] @@ -320,7 +320,7 @@ def viewmore(v, pid, sort, offset): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - first = comments.filter(Comment.slots_result == None, Comment.blackjack_result == None, func.length(Comment.body) > 20).all() + first = comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None), func.length(Comment.body) > 20)).all() second = comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None), func.length(Comment.body) <= 20).all() comments = first + second comments = comments[offset:]