diff --git a/files/routes/comments.py b/files/routes/comments.py index b44b7cd03..c8befb0d4 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -78,7 +78,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): current_ids = [comment.id] - for i in range(6 - context): + for i in range(200 - context): if v: votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery() @@ -111,6 +111,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): isouter=True ) + if comments.count() == 0: break + if sort == "top": comments = sorted(comments.all(), key=lambda x: x[0].score, reverse=True) elif sort == "bottom": @@ -143,6 +145,8 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): Comment.parent_comment_id.in_(current_ids) ) + if comments.count() == 0: break + if sort == "top": output = sorted(comments.all(), key=lambda x: x.score, reverse=True) elif sort == "bottom":