mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Use include-subcategories filter in report export (#10007)
Some filters were renamed and the conversion of the filter names and arguments was removed.
This commit is contained in:
@@ -226,14 +226,18 @@ export default Component.extend({
|
||||
|
||||
@action
|
||||
exportCsv() {
|
||||
const customFilters = this.get("filters.customFilters") || {};
|
||||
exportEntity("report", {
|
||||
const args = {
|
||||
name: this.get("model.type"),
|
||||
start_date: this.startDate.toISOString(true).split("T")[0],
|
||||
end_date: this.endDate.toISOString(true).split("T")[0],
|
||||
category_id: customFilters.category,
|
||||
group_id: customFilters.group
|
||||
}).then(outputExportResult);
|
||||
end_date: this.endDate.toISOString(true).split("T")[0]
|
||||
};
|
||||
|
||||
const customFilters = this.get("filters.customFilters");
|
||||
if (customFilters) {
|
||||
Object.assign(args, customFilters);
|
||||
}
|
||||
|
||||
exportEntity("report", args).then(outputExportResult);
|
||||
},
|
||||
|
||||
@action
|
||||
|
||||
@@ -18,7 +18,7 @@ class ExportCsvController < ApplicationController
|
||||
def export_params
|
||||
@_export_params ||= begin
|
||||
params.require(:entity)
|
||||
params.permit(:entity, args: [:name, :start_date, :end_date, :category_id, :group_id, :trust_level]).to_h
|
||||
params.permit(:entity, args: Report::FILTERS).to_h
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -215,12 +215,9 @@ module Jobs
|
||||
end
|
||||
|
||||
@extra[:filters] = {}
|
||||
if @extra[:category_id].present?
|
||||
@extra[:filters][:category] = @extra[:category_id].to_i
|
||||
end
|
||||
if @extra[:group_id].present?
|
||||
@extra[:filters][:group] = @extra[:group_id].to_i
|
||||
end
|
||||
@extra[:filters][:category] = @extra[:category].to_i if @extra[:category].present?
|
||||
@extra[:filters][:group] = @extra[:group].to_i if @extra[:group].present?
|
||||
@extra[:filters][:include_subcategories] = !!ActiveRecord::Type::Boolean.new.cast(@extra[:include_subcategories]) if @extra[:include_subcategories].present?
|
||||
|
||||
report = Report.find(@extra[:name], @extra)
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ class Report
|
||||
# and you want to ensure cache is reset
|
||||
SCHEMA_VERSION = 4
|
||||
|
||||
FILTERS = [:name, :start_date, :end_date, :category, :group, :trust_level, :file_extension, :include_subcategories]
|
||||
|
||||
attr_accessor :type, :data, :total, :prev30Days, :start_date,
|
||||
:end_date, :labels, :prev_period, :facets, :limit, :average,
|
||||
:percent, :higher_is_better, :icon, :modes, :prev_data,
|
||||
@@ -80,9 +82,9 @@ class Report
|
||||
add_filter('category', type: 'category', default: category_id)
|
||||
return if category_id.blank?
|
||||
|
||||
include_subcategories = filters[:'include-subcategories']
|
||||
include_subcategories = filters[:include_subcategories]
|
||||
include_subcategories = !!ActiveRecord::Type::Boolean.new.cast(include_subcategories)
|
||||
add_filter('include-subcategories', type: 'bool', default: include_subcategories)
|
||||
add_filter('include_subcategories', type: 'bool', default: include_subcategories)
|
||||
|
||||
[category_id, include_subcategories]
|
||||
end
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
Report.add_report('top_uploads') do |report|
|
||||
report.modes = [:table]
|
||||
|
||||
extension_filter = report.filters.dig(:"file-extension")
|
||||
report.add_filter('file-extension',
|
||||
extension_filter = report.filters.dig(:file_extension)
|
||||
report.add_filter('file_extension',
|
||||
type: 'list',
|
||||
default: extension_filter || 'any',
|
||||
choices: (SiteSetting.authorized_extensions.split('|') + Array(extension_filter)).uniq
|
||||
|
||||
Reference in New Issue
Block a user