mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: in:tagged search (srv side) (#7822)
* FEATURE: in:tagged and in:untagged advanced search filters Similar to in:solved or in:unsolved, the filters check for an existence of the topic_id in the topic_tags table. see: https://meta.discourse.org/t/how-to-search-filter-untagged-topics/119641/2
This commit is contained in:
@@ -265,6 +265,18 @@ class Search
|
||||
@advanced_filters
|
||||
end
|
||||
|
||||
advanced_filter(/^in:tagged$/) do |posts|
|
||||
posts
|
||||
.where('EXISTS (SELECT 1 FROM topic_tags WHERE topic_tags.topic_id = posts.topic_id)')
|
||||
end
|
||||
|
||||
advanced_filter(/^in:untagged$/) do |posts|
|
||||
posts
|
||||
.joins("LEFT JOIN topic_tags ON
|
||||
topic_tags.topic_id = posts.topic_id")
|
||||
.where("topic_tags.id IS NULL")
|
||||
end
|
||||
|
||||
advanced_filter(/^status:open$/) do |posts|
|
||||
posts.where('NOT topics.closed AND NOT topics.archived')
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user