2019-04-26 18:17:10 +08:00
|
|
|
Report.add_report('top_referred_topics') do |report|
|
|
|
|
category_filter = report.filters.dig(:category)
|
|
|
|
report.add_filter('category', default: category_filter)
|
2019-03-29 17:54:56 +08:00
|
|
|
|
|
|
|
report.modes = [:table]
|
|
|
|
|
|
|
|
report.labels = [
|
|
|
|
{
|
|
|
|
type: :topic,
|
|
|
|
properties: {
|
|
|
|
title: :topic_title,
|
|
|
|
id: :topic_id
|
|
|
|
},
|
2019-04-26 18:17:10 +08:00
|
|
|
title: I18n.t('reports.top_referred_topics.labels.topic')
|
2019-03-29 17:54:56 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: :num_clicks,
|
|
|
|
type: :number,
|
2019-04-26 18:17:10 +08:00
|
|
|
title: I18n.t('reports.top_referred_topics.labels.num_clicks')
|
2019-03-29 17:54:56 +08:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
options = {
|
|
|
|
end_date: report.end_date,
|
|
|
|
start_date: report.start_date,
|
|
|
|
limit: report.limit || 8,
|
2019-04-26 18:17:10 +08:00
|
|
|
category_id: category_filter
|
2019-03-29 17:54:56 +08:00
|
|
|
}
|
|
|
|
result = nil
|
|
|
|
result = IncomingLinksReport.find(:top_referred_topics, options)
|
|
|
|
report.data = result.data
|
|
|
|
end
|