From a68e85d45142516aa9c017bb4670381aff72dc61 Mon Sep 17 00:00:00 2001 From: atrc445 Date: Sun, 22 Aug 2021 13:58:41 +0200 Subject: [PATCH] count snappy/autojanny --- files/routes/comments.py | 7 +++---- files/routes/posts.py | 3 +++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/files/routes/comments.py b/files/routes/comments.py index adeae9fce..ef6c901c5 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -273,10 +273,6 @@ def api_comment(v): g.db.add(c) g.db.flush() - parent_post.comment_count = g.db.query(Comment).filter_by(parent_submission=parent_post.id).count() - g.db.add(parent_post) - g.db.flush() - if request.files.get("file") and request.headers.get("cf-ipcountry") != "T1": file=request.files["file"] if not file.content_type.startswith('image/'): return {"error": "That wasn't an image!"}, 400 @@ -511,6 +507,9 @@ def api_comment(v): v.comment_count = v.comments.filter(Comment.parent_submission != None).filter_by(is_banned=False, deleted_utc=0).count() g.db.add(v) + parent_post.comment_count = g.db.query(Comment).filter_by(parent_submission=parent_post.id).count() + g.db.add(parent_post) + g.db.flush() if request.headers.get("Authorization"): return c.json else: return jsonify({"html": render_template("comments.html", diff --git a/files/routes/posts.py b/files/routes/posts.py index 811c407fd..257917a20 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -884,6 +884,9 @@ def submit_post(v): g.db.add(c) g.db.flush() + new_post.comment_count = g.db.query(Comment).filter_by(parent_submission=new_post.id).count() + g.db.add(new_post) + if "rdrama" in request.host: if v.id == 995: body = "fuck off carp" else: body = random.choice(snappyquotes)