2020-10-30 00:49:09 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Reports::TopReferrers
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
class_methods do
|
|
|
|
def report_top_referrers(report)
|
|
|
|
report.modes = [:table]
|
|
|
|
|
|
|
|
report.labels = [
|
|
|
|
{
|
|
|
|
type: :user,
|
|
|
|
properties: {
|
|
|
|
username: :username,
|
|
|
|
id: :user_id,
|
|
|
|
avatar: :user_avatar_template,
|
|
|
|
},
|
2023-01-09 20:20:10 +08:00
|
|
|
title: I18n.t("reports.top_referrers.labels.user"),
|
2020-10-30 00:49:09 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: :num_clicks,
|
|
|
|
type: :number,
|
2023-01-09 20:20:10 +08:00
|
|
|
title: I18n.t("reports.top_referrers.labels.num_clicks"),
|
2020-10-30 00:49:09 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: :num_topics,
|
|
|
|
type: :number,
|
2023-01-09 20:20:10 +08:00
|
|
|
title: I18n.t("reports.top_referrers.labels.num_topics"),
|
|
|
|
},
|
2020-10-30 00:49:09 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
options = {
|
|
|
|
end_date: report.end_date,
|
|
|
|
start_date: report.start_date,
|
2023-01-09 20:20:10 +08:00
|
|
|
limit: report.limit || 8,
|
2020-10-30 00:49:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
result = IncomingLinksReport.find(:top_referrers, options)
|
|
|
|
report.data = result.data
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|