Skip to content

A platform for community discussion. Free, open, simple.

FIX: web_crawlers had been mistakenly removed (#7342)

Joffrey JAFFEUXdf7f37f10a12
diff --git a/app/models/report.rb b/app/models/report.rb
index c866d73f280..e5b5e4e37bf 100644
--- a/app/models/report.rb
+++ b/app/models/report.rb
@@ -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"
diff --git a/app/models/reports/web_crawlers.rb b/app/models/reports/web_crawlers.rb
new file mode 100644
index 00000000000..c3d9da9b45d
--- /dev/null
+++ b/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