2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-26 18:17:10 +08:00
|
|
|
Report.add_report('top_traffic_sources') 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 = [
|
|
|
|
{
|
|
|
|
property: :domain,
|
2019-04-26 18:17:10 +08:00
|
|
|
title: I18n.t('reports.top_traffic_sources.labels.domain')
|
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_traffic_sources.labels.num_clicks')
|
2019-03-29 17:54:56 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: :num_topics,
|
|
|
|
type: :number,
|
2019-04-26 18:17:10 +08:00
|
|
|
title: I18n.t('reports.top_traffic_sources.labels.num_topics')
|
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 = IncomingLinksReport.find(:top_traffic_sources, options)
|
|
|
|
report.data = result.data
|
|
|
|
end
|