From 9f27caf39c70e0d8dd4d6e95851d72e5dedfb3d4 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Wed, 1 May 2019 22:24:09 +0200 Subject: [PATCH] FIX: adds support for new filter syntax --- plugin.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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)")