From 6885ee04607b10db948cef4796cbb7388837018e Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 5 Dec 2021 04:23:39 +0200 Subject: [PATCH] VIEW MORE --- files/routes/posts.py | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index 56cdd1d1bc..f483ede15f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -171,17 +171,7 @@ def post_id(pid, anything=None, v=None): comment.is_blocked = c[3] or 0 output.append(comment) - comments = [] - count = 0 - for comment in output: - comments.append(comment) - count += g.db.query(Comment.id).filter_by(top_comment_id=comment.id).count() - offset += 1 - if count > 3: break - - if len(output) == len(comments): offset = None - - post.replies = pinned + comments + comments = output else: comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID, Comment.level == 1, Comment.is_pinned == None) @@ -201,18 +191,19 @@ def post_id(pid, anything=None, v=None): comments = comments.all() - comments2 = [] - count = 0 - for comment in comments: - comments2.append(comment) - count += g.db.query(Comment.id).filter_by(top_comment_id=comment.id).count() - offset += 1 - if count > 3: break + comments2 = [] + count = 0 + for comment in comments: + comments2.append(comment) + count += g.db.query(Comment.id).filter_by(top_comment_id=comment.id).count() + offset += 1 + if count > 50: break + + if len(comments) == len(comments2): offset = None + + post.replies = pinned + comments2 - if len(comments) == len(comments2): offset = None - post.replies = pinned + comments2 - if request.host == 'rdrama.net' and pid in [BUG_THREAD, EMOJI_THREAD] and not request.values.get("sort"): post.replies = post.replies[:10] post.views += 1