2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-29 17:54:56 +08:00
|
|
|
Report.add_report("top_referrers") do |report|
|
|
|
|
report.modes = [:table]
|
|
|
|
|
|
|
|
report.labels = [
|
|
|
|
{
|
|
|
|
type: :user,
|
|
|
|
properties: {
|
|
|
|
username: :username,
|
|
|
|
id: :user_id,
|
|
|
|
avatar: :user_avatar_template,
|
|
|
|
},
|
|
|
|
title: I18n.t("reports.top_referrers.labels.user")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: :num_clicks,
|
|
|
|
type: :number,
|
|
|
|
title: I18n.t("reports.top_referrers.labels.num_clicks")
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: :num_topics,
|
|
|
|
type: :number,
|
|
|
|
title: I18n.t("reports.top_referrers.labels.num_topics")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
options = {
|
|
|
|
end_date: report.end_date,
|
|
|
|
start_date: report.start_date,
|
|
|
|
limit: report.limit || 8
|
|
|
|
}
|
|
|
|
|
|
|
|
result = IncomingLinksReport.find(:top_referrers, options)
|
|
|
|
report.data = result.data
|
|
|
|
end
|