FIX: web_crawlers had been mistakenly removed (#7342)

This commit is contained in:
Joffrey JAFFEUX 2019-04-09 09:26:22 +02:00 committed by GitHub
parent a89c90ed5d
commit df7f37f10a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -374,3 +374,4 @@ require_relative "reports/posts"
require_relative "reports/time_to_first_response"
require_relative "reports/topics_with_no_response"
require_relative "reports/emails"
require_relative "reports/web_crawlers"

View File

@ -0,0 +1,22 @@
Report.add_report('web_crawlers') do |report|
report.labels = [
{
type: :string,
property: :user_agent,
title: I18n.t('reports.web_crawlers.labels.user_agent')
},
{
property: :count,
type: :number,
title: I18n.t('reports.web_crawlers.labels.page_views')
}
]
report.modes = [:table]
report.data = WebCrawlerRequest.where('date >= ? and date <= ?', report.start_date, report.end_date)
.limit(200)
.order('sum_count DESC')
.group(:user_agent).sum(:count)
.map { |ua, count| { user_agent: ua, count: count } }
end