FIX: adds support for new filter syntax

FIX: adds support for new filter syntax

diff --git a/plugin.rb b/plugin.rb
index fe7c99b..2974f7e 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -292,8 +292,21 @@ SQL
   if Report.respond_to?(:add_report)
     Report.add_report("accepted_solutions") do |report|
       report.data = []
+
       accepted_solutions = TopicCustomField.where(name: "accepted_answer_post_id")
-      accepted_solutions = accepted_solutions.joins(:topic).where("topics.category_id = ?", report.category_id) if report.category_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 = ?", category_filter)
+        end
+      else
+        if report.category_id
+          accepted_solutions = accepted_solutions.joins(:topic).where("topics.category_id = ?", report.category_id)
+        end
+      end
+
       accepted_solutions.where("topic_custom_fields.created_at >= ?", report.start_date)
         .where("topic_custom_fields.created_at <= ?", report.end_date)
         .group("DATE(topic_custom_fields.created_at)")

GitHub sha: 9f27caf3

1 Like