diff --git a/plugin.rb b/plugin.rb index 452195f..861a9ac 100644 --- a/plugin.rb +++ b/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