Make search skip over hidden posts

This commit is contained in:
swaggboi 2023-11-07 14:50:29 -05:00
parent ff1933de17
commit 1643fcba89

View File

@ -23,6 +23,7 @@ sub search($self, $search_query, $this_page = 1) {
TS_RANK(search_tokens, PLAINTO_TSQUERY('english', $2)) AS search_rank TS_RANK(search_tokens, PLAINTO_TSQUERY('english', $2)) AS search_rank
FROM threads FROM threads
WHERE search_tokens @@ PLAINTO_TSQUERY('english', $2) WHERE search_tokens @@ PLAINTO_TSQUERY('english', $2)
AND NOT hidden_status
UNION ALL UNION ALL
SELECT 'remark', SELECT 'remark',
remark_id, remark_id,
@ -32,6 +33,7 @@ sub search($self, $search_query, $this_page = 1) {
TS_RANK(search_tokens, PLAINTO_TSQUERY('english', $2)) TS_RANK(search_tokens, PLAINTO_TSQUERY('english', $2))
FROM remarks FROM remarks
WHERE search_tokens @@ PLAINTO_TSQUERY('english', $2) WHERE search_tokens @@ PLAINTO_TSQUERY('english', $2)
AND NOT hidden_status
ORDER BY search_rank DESC, post_date DESC ORDER BY search_rank DESC, post_date DESC
LIMIT $3 OFFSET $4; LIMIT $3 OFFSET $4;
END_SQL END_SQL
@ -43,10 +45,12 @@ sub count_for($self, $search_query) {
FROM (SELECT thread_date AS post_date FROM (SELECT thread_date AS post_date
FROM threads FROM threads
WHERE search_tokens @@ PLAINTO_TSQUERY('english', $1) WHERE search_tokens @@ PLAINTO_TSQUERY('english', $1)
AND NOT hidden_status
UNION ALL UNION ALL
SELECT remark_date SELECT remark_date
FROM remarks FROM remarks
WHERE search_tokens @@ PLAINTO_TSQUERY('english', $1)) WHERE search_tokens @@ PLAINTO_TSQUERY('english', $1)
AND NOT hidden_status)
AS posts; AS posts;
END_SQL END_SQL
} }