From 74a5ea88ac360a7d797f131045980aa1181f2906 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Mon, 13 Jun 2022 19:33:20 +0200 Subject: [PATCH] expand post searching to include bodies (instead of titles only) --- files/routes/search.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/files/routes/search.py b/files/routes/search.py index 85866440d..097f6a435 100644 --- a/files/routes/search.py +++ b/files/routes/search.py @@ -89,8 +89,8 @@ def searchposts(v): if 'q' in criteria: words=criteria['q'].split() words = criteria['q'].replace('\\', '').replace('_', '\_').replace('%', '\%').strip().split() - words=[Submission.title.ilike('%'+x+'%') for x in words] - posts=posts.filter(*words) + words = [or_(Submission.title.ilike('%'+x+'%'), Submission.body.ilike('%'+x+'%')) for x in words] + posts = posts.filter(*words) if 'over18' in criteria: posts = posts.filter(Submission.over_18==True) @@ -287,4 +287,4 @@ def searchusers(v): users=users[:25] if request.headers.get("Authorization"): return {"data": [x.json for x in users]} - return render_template("search_users.html", v=v, query=query, total=total, page=page, users=users, sort=sort, t=t, next_exists=next_exists) \ No newline at end of file + return render_template("search_users.html", v=v, query=query, total=total, page=page, users=users, sort=sort, t=t, next_exists=next_exists)