mirror of
https://github.com/discourse/discourse-solved.git
synced 2025-02-16 08:34:56 +00:00
WIP: Add include_subcategories report filter
This commit is contained in:
parent
dafb1d7c7f
commit
f30f1a295f
@ -0,0 +1,11 @@
|
|||||||
|
import FilterComponent from "admin/components/report-filters/filter";
|
||||||
|
|
||||||
|
export default FilterComponent.extend({
|
||||||
|
value: null,
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
onChange(value) {
|
||||||
|
this.applyFilter(this.get("filter.id"), !!value);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
@ -0,0 +1 @@
|
|||||||
|
{{input type="checkbox" checked=value click=(action "onChange")}}
|
@ -34,6 +34,11 @@ en:
|
|||||||
solved: "are solved"
|
solved: "are solved"
|
||||||
|
|
||||||
admin:
|
admin:
|
||||||
|
dashboard:
|
||||||
|
reports:
|
||||||
|
filters:
|
||||||
|
include_subcategories:
|
||||||
|
label: "Include Subcategories"
|
||||||
web_hooks:
|
web_hooks:
|
||||||
solved_event:
|
solved_event:
|
||||||
name: "Solved Event"
|
name: "Solved Event"
|
||||||
|
15
plugin.rb
15
plugin.rb
@ -313,15 +313,20 @@ SQL
|
|||||||
|
|
||||||
accepted_solutions = TopicCustomField.where(name: "accepted_answer_post_id")
|
accepted_solutions = TopicCustomField.where(name: "accepted_answer_post_id")
|
||||||
|
|
||||||
if report.respond_to?(:add_filter)
|
|
||||||
category_filter = report.filters.dig(:category)
|
category_filter = report.filters.dig(:category)
|
||||||
|
include_subcategories_filter = ActiveModel::Type::Boolean.new.cast(report.filters.dig(:include_subcategories))
|
||||||
report.add_filter('category', default: category_filter)
|
report.add_filter('category', default: category_filter)
|
||||||
|
report.add_filter('include_subcategories')
|
||||||
|
|
||||||
if category_filter
|
if category_filter
|
||||||
accepted_solutions = accepted_solutions.joins(:topic).where("topics.category_id IN (?)", Category.subcategory_ids(category_filter.to_i))
|
if include_subcategories_filter
|
||||||
end
|
accepted_solutions = accepted_solutions
|
||||||
|
.joins(:topic)
|
||||||
|
.where("topics.category_id IN (?)", Category.subcategory_ids(category_filter.to_i))
|
||||||
else
|
else
|
||||||
if report.category_id
|
accepted_solutions = accepted_solutions
|
||||||
accepted_solutions = accepted_solutions.joins(:topic).where("topics.category_id IN (?)", Category.subcategory_ids(report.category_id.to_i))
|
.joins(:topic)
|
||||||
|
.where("topics.category_id = ?", category_filter)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user