discourse/app/models/reports/top_referred_topics.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

35 lines
818 B
Ruby

# frozen_string_literal: true
Report.add_report('top_referred_topics') do |report|
category_id, include_subcategories = report.add_category_filter
report.modes = [:table]
report.labels = [
{
type: :topic,
properties: {
title: :topic_title,
id: :topic_id
},
title: I18n.t('reports.top_referred_topics.labels.topic')
},
{
property: :num_clicks,
type: :number,
title: I18n.t('reports.top_referred_topics.labels.num_clicks')
}
]
options = {
end_date: report.end_date,
start_date: report.start_date,
limit: report.limit || 8,
category_id: category_id,
include_subcategories: include_subcategories
}
result = nil
result = IncomingLinksReport.find(:top_referred_topics, options)
report.data = result.data
end