Skip to content

Commit

Permalink
FIX: web_crawlers had been mistakenly removed (#7342)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjaffeux committed Apr 9, 2019
1 parent a89c90e commit df7f37f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/report.rb
Expand Up @@ -374,3 +374,4 @@ def hex_to_rgbs(hex_color)
require_relative "reports/time_to_first_response"
require_relative "reports/topics_with_no_response"
require_relative "reports/emails"
require_relative "reports/web_crawlers"
22 changes: 22 additions & 0 deletions app/models/reports/web_crawlers.rb
@@ -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

0 comments on commit df7f37f

Please sign in to comment.