diff --git a/files/routes/comments.py b/files/routes/comments.py index fa06aa1ef..8c57732a8 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -214,8 +214,7 @@ def api_comment(v): process_image(filename, 200) requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache', headers=CF_HEADERS, data={'files': [f"https://{request.host}/static/assets/images/badges/{badge.id}.webp"]}) except Exception as e: - print(e) - return {"error": "You didn't follow the format retard"}, 400 + return {"error": e}, 400 elif v.admin_level > 2 and parent_post.id == 37838: try: marsey = loads(body.lower()) @@ -232,8 +231,7 @@ def api_comment(v): requests.post(f'https://api.cloudflare.com/client/v4/zones/{CF_ZONE}/purge_cache', headers=CF_HEADERS, data={'files': [f"https://{request.host}/static/assets/images/emojis/{name}.webp"]}) cache.delete_memoized(marsey_list) except Exception as e: - print(e) - return {"error": "You didn't follow the format retard"}, 400 + return {"error": e}, 400 body += f"\n\n![]({image})" elif file.content_type.startswith('video/'): file.save("video.mp4") @@ -568,9 +566,6 @@ def api_comment(v): v.comment_count = g.db.query(Comment.id).filter(Comment.author_id == v.id, Comment.parent_submission != None).filter_by(is_banned=False, deleted_utc=0).count() g.db.add(v) - parent_post.comment_count += 1 - g.db.add(parent_post) - c.voted = 1 if v.id == PIZZASHILL_ID: @@ -603,6 +598,10 @@ def api_comment(v): treasure = Treasure(g) treasure.check_for_treasure(body, c) + if not c.slots_result and not c.blackjack_result: + parent_post.comment_count += 1 + g.db.add(parent_post) + g.db.commit() if request.headers.get("Authorization"): return c.json diff --git a/files/routes/front.py b/files/routes/front.py index 8ee2e91ca..2c74417ae 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -294,7 +294,7 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' if sort == "hot": ti = int(time.time()) + 3600 - posts = posts.order_by(-1000000*(Submission.realupvotes + 1)/(func.power(((ti - Submission.created_utc)/1000), 1.23))) + posts = posts.order_by(-1000000*(Submission.realupvotes + 1 + Submission.comment_count/5)/(func.power(((ti - Submission.created_utc)/1000), 1.23))) elif sort == "new": posts = posts.order_by(Submission.created_utc.desc()) elif sort == "old": diff --git a/files/routes/posts.py b/files/routes/posts.py index 975be862f..fa0740f6f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -179,7 +179,9 @@ def post_id(pid, anything=None, v=None): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - comments = [c[0] for c in comments.all()] + 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()] + comments = first + second else: pinned = g.db.query(Comment).filter(Comment.parent_submission == post.id, Comment.is_pinned != None).all() @@ -196,7 +198,9 @@ def post_id(pid, anything=None, v=None): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - comments = comments.all() + 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() + comments = first + second offset = 0 @@ -298,9 +302,10 @@ def viewmore(v, pid, sort, offset): elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - comments = comments.offset(offset) - - comments = [c[0] for c in comments.all()] + 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()] + comments = first + second + comments = comments[offset:] else: comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == pid, Comment.author_id.notin_((AUTOPOLLER_ID, AUTOBETTER_ID)), Comment.level == 1, Comment.is_pinned == None) @@ -314,10 +319,11 @@ def viewmore(v, pid, sort, offset): comments = comments.order_by(Comment.realupvotes.desc()) elif sort == "bottom": comments = comments.order_by(Comment.upvotes - Comment.downvotes) - - comments = comments.offset(offset) - comments = comments.all() + 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() + comments = first + second + comments = comments[offset:] comments2 = [] count = 0