FEATURE: Add include_subcategories report filter
Follow up to dafb1d7c7f
.
This commit is contained in:
parent
dafb1d7c7f
commit
dc87d34594
15
plugin.rb
15
plugin.rb
|
@ -313,15 +313,12 @@ SQL
|
|||
|
||||
accepted_solutions = TopicCustomField.where(name: "accepted_answer_post_id")
|
||||
|
||||
if report.respond_to?(:add_filter)
|
||||
category_filter = report.filters.dig(:category)
|
||||
report.add_filter('category', default: category_filter)
|
||||
if category_filter
|
||||
accepted_solutions = accepted_solutions.joins(:topic).where("topics.category_id IN (?)", Category.subcategory_ids(category_filter.to_i))
|
||||
end
|
||||
else
|
||||
if report.category_id
|
||||
accepted_solutions = accepted_solutions.joins(:topic).where("topics.category_id IN (?)", Category.subcategory_ids(report.category_id.to_i))
|
||||
category_id, include_subcategories = report.add_category_filter
|
||||
if category_id
|
||||
if include_subcategories
|
||||
accepted_solutions = accepted_solutions.joins(:topic).where('topics.category_id IN (?)', Category.subcategory_ids(category_id))
|
||||
else
|
||||
accepted_solutions = accepted_solutions.joins(:topic).where('topics.category_id = ?', category_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue