mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
FIX: web_crawlers had been mistakenly removed (#7342)
This commit is contained in:
parent
a89c90ed5d
commit
df7f37f10a
@ -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"
|
||||
|
22
app/models/reports/web_crawlers.rb
Normal file
22
app/models/reports/web_crawlers.rb
Normal 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
|
Loading…
Reference in New Issue
Block a user