discourse/app/models/reports/flags.rb
Dan Ungureanu e733701887
FEATURE: Make report filters reusable (#9444)
This commit also adds 'include subcategories' report filter
2020-04-22 11:52:50 +03:00

31 lines
736 B
Ruby

# frozen_string_literal: true
Report.add_report('flags') do |report|
category_id, include_subcategories = report.add_category_filter
report.icon = 'flag'
report.higher_is_better = false
basic_report_about(
report,
ReviewableFlaggedPost,
:count_by_date,
report.start_date,
report.end_date,
category_id,
include_subcategories
)
countable = ReviewableFlaggedPost.scores_with_topics
if category_id
if include_subcategories
countable = countable.where('topics.category_id IN (?)', Category.subcategory_ids(category_id))
else
countable = countable.where('topics.category_id = ?', category_id)
end
end
add_counts report, countable, 'reviewable_scores.created_at'
end