From d667472212d09b6c692a60a9a7d15ac62a5c7a26 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 1 Jul 2022 03:39:05 +0200 Subject: [PATCH] to devrama --- files/routes/posts.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/files/routes/posts.py b/files/routes/posts.py index eb76ba93e..dfbeb75fb 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -170,7 +170,7 @@ def post_id(pid, anything=None, v=None, sub=None): blocked, blocked.c.user_id == Comment.author_id, isouter=True - ) + ).options(joinedload(Comment.flags), joinedload(Comment.awards), joinedload(Comment.author), joinedload(Comment.author, User.badges)) output = [] for c in comments.all(): @@ -186,7 +186,16 @@ def post_id(pid, anything=None, v=None, sub=None): comments = sort_comments(sort, comments) + t = time.time() first = [c[0] for c in comments.filter(or_(and_(Comment.slots_result == None, Comment.blackjack_result == None, Comment.wordle_result == None), func.length(Comment.body_html) > 100)).all()] + print(time.time() - t, flush=True) + + + t = time.time() + first = [c[0] for c in comments if (c[0].slots_result == None and c[0].blackjack_result == None and c[0].wordle_result == None) or len(c[0].body_html) > 100] + print(time.time() - t, flush=True) + + second = [c[0] for c in comments.filter(or_(Comment.slots_result != None, Comment.blackjack_result != None, Comment.wordle_result != None), func.length(Comment.body_html) <= 100).all()] comments = first + second else: