This commit is contained in:
Aevann1 2021-12-06 00:52:39 +02:00
parent d059eb7cab
commit a490e5a44e
4 changed files with 65 additions and 38 deletions

View file

@ -190,7 +190,7 @@ def post_id(pid, anything=None, v=None):
offset = 0
if post.comment_count > 60:
if len(comments) > 60:
comments2 = []
count = 0
if post.created_utc > 1638672040:
@ -229,6 +229,7 @@ def post_id(pid, anything=None, v=None):
@limiter.limit("1/second")
@auth_desired
def viewmore(v, pid, sort, offset):
offset = int(offset)
if v:
votes = g.db.query(CommentVote).filter_by(user_id=v.id).subquery()
@ -283,7 +284,7 @@ def viewmore(v, pid, sort, offset):
elif sort == "bottom":
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
if offset: comments = comments.offset(int(offset))
comments = comments.offset(offset)
comments = [c[0] for c in comments.all()]
else:
@ -300,11 +301,32 @@ def viewmore(v, pid, sort, offset):
elif sort == "bottom":
comments = comments.order_by(Comment.upvotes - Comment.downvotes)
if offset: comments = comments.offset(int(offset))
comments = comments.offset(offset)
comments = comments.all()
return render_template("comments.html", v=v, comments=comments, render_replies=True)
if len(comments) > 60:
comments2 = []
count = 0
post = get_post(pid, v=v)
if post.created_utc > 1638672040:
for comment in comments:
comments2.append(comment)
count += g.db.query(Comment.id).filter_by(parent_submission=post.id, top_comment_id=comment.id).count() + 1
offset += 1
if count > 50: break
else:
for comment in comments:
comments2.append(comment)
count += g.db.query(Comment.id).filter_by(parent_submission=post.id, parent_comment_id=comment.id).count() + 1
offset += 1
if count > 10: break
if len(comments) == len(comments2): offset = None
comments = comments2
else: offset = None
return render_template("comments.html", v=v, comments=comments, render_replies=True, pid=pid, sort=sort, offset=offset)
@app.post("/edit_post/<pid>")