mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 01:55:46 +08:00
If you search a category by id, also include its children
This commit is contained in:
@ -275,9 +275,9 @@ class Search
|
||||
end
|
||||
|
||||
advanced_filter(/category:(.+)/) do |posts,match|
|
||||
category_id = Category.where('name ilike ? OR id = ?', match, match.to_i).pluck(:id).first
|
||||
if category_id
|
||||
posts.where("topics.category_id = ?", category_id)
|
||||
category_ids = Category.where('name ilike ? OR id = ? OR parent_category_id = ?', match, match.to_i, match.to_i).pluck(:id)
|
||||
if category_ids.present?
|
||||
posts.where("topics.category_id IN (?)", category_ids)
|
||||
else
|
||||
posts.where("1 = 0")
|
||||
end
|
||||
|
Reference in New Issue
Block a user