From 444cbb41bb128e981903d8e4687e2c987b5d8a12 Mon Sep 17 00:00:00 2001 From: Aevann Date: Wed, 22 Mar 2023 22:16:52 +0200 Subject: [PATCH] do this https://rdrama.net/post/18459/marseycapywalking-megathread-for-bugs-and-suggestions/3842547#context --- files/routes/search.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/files/routes/search.py b/files/routes/search.py index d5119574ae..3beff1d212 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -300,7 +300,7 @@ def searchmessages(v:User): if v.admin_level >= PERMS['VIEW_MODMAIL']: dm_conditions.append(Comment.sentto == MODMAIL_ID), - comments = g.db.query(Comment.id) \ + comments = g.db.query(Comment) \ .filter( Comment.sentto != None, Comment.parent_submission == None, @@ -359,15 +359,15 @@ def searchmessages(v:User): comments = comments.offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE+1).all() - ids = [x[0] for x in comments] + next_exists = (len(comments) > PAGE_SIZE) + comments = comments[:PAGE_SIZE] - next_exists = (len(ids) > PAGE_SIZE) - ids = ids[:PAGE_SIZE] - - comments = get_comments(ids, v=v) + for x in comments: x.unread = True + + comments = [x.top_comment for x in comments] if v.client: return {"total":total, "data":[x.json(db=g.db) for x in comments]} - return render_template("search_comments.html", v=v, query=query, total=total, page=page, comments=comments, sort=sort, t=t, next_exists=next_exists, standalone=True) + return render_template("search_comments.html", v=v, query=query, total=total, page=page, comments=comments, sort=sort, t=t, next_exists=next_exists, standalone=True, render_replies=True) @app.get("/search/users") @limiter.limit(DEFAULT_RATELIMIT)