From 1643fcba893c2f6c5d6eb28f09cc34e157755801 Mon Sep 17 00:00:00 2001 From: swaggboi Date: Tue, 7 Nov 2023 14:50:29 -0500 Subject: [PATCH] Make search skip over hidden posts --- lib/PostText/Model/Page.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/PostText/Model/Page.pm b/lib/PostText/Model/Page.pm index a4b5651..0d17a4f 100644 --- a/lib/PostText/Model/Page.pm +++ b/lib/PostText/Model/Page.pm @@ -23,6 +23,7 @@ sub search($self, $search_query, $this_page = 1) { TS_RANK(search_tokens, PLAINTO_TSQUERY('english', $2)) AS search_rank FROM threads WHERE search_tokens @@ PLAINTO_TSQUERY('english', $2) + AND NOT hidden_status UNION ALL SELECT 'remark', remark_id, @@ -32,6 +33,7 @@ sub search($self, $search_query, $this_page = 1) { TS_RANK(search_tokens, PLAINTO_TSQUERY('english', $2)) FROM remarks WHERE search_tokens @@ PLAINTO_TSQUERY('english', $2) + AND NOT hidden_status ORDER BY search_rank DESC, post_date DESC LIMIT $3 OFFSET $4; END_SQL @@ -43,10 +45,12 @@ sub count_for($self, $search_query) { FROM (SELECT thread_date AS post_date FROM threads WHERE search_tokens @@ PLAINTO_TSQUERY('english', $1) + AND NOT hidden_status UNION ALL SELECT remark_date FROM remarks - WHERE search_tokens @@ PLAINTO_TSQUERY('english', $1)) + WHERE search_tokens @@ PLAINTO_TSQUERY('english', $1) + AND NOT hidden_status) AS posts; END_SQL }