diff --git a/files/routes/posts.py b/files/routes/posts.py index 5235d226e..d4484a05a 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -179,8 +179,8 @@ 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).all()] - second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None)).all()] + first = [c[0] for c in comments.filter(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: pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all() @@ -198,8 +198,8 @@ 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).all() - second = comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None)).all() + first = comments.filter(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 offset = 0 @@ -302,8 +302,8 @@ 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).all()] - second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None)).all()] + first = [c[0] for c in comments.filter(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:] else: @@ -320,8 +320,8 @@ 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).all() - second = comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None)).all() + first = comments.filter(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:]