mirror of
https://github.com/discourse/discourse.git
synced 2025-02-05 19:11:13 +00:00
4580844c56
Followup 94fe31e5b37c6dc9296a191cf2f7013419a3f50e, change the color of the "Known Crawler" bar on the new "Consolidated Pageviews with Browser Detection (Experimental)" report to be purple, like it was on the original "Consolidated Pageviews" report to allow for easier visual comparison. Also removes the report colors to named keys in a hash for easier reference than having to look up the index of the array all the time.
39 lines
1.1 KiB
Ruby
39 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Reports::ConsolidatedPageViews
|
|
extend ActiveSupport::Concern
|
|
|
|
class_methods do
|
|
def report_consolidated_page_views(report)
|
|
filters = %w[page_view_logged_in page_view_anon page_view_crawler]
|
|
|
|
report.modes = [:stacked_chart]
|
|
|
|
requests =
|
|
filters.map do |filter|
|
|
color = report.colors[:turquoise]
|
|
color = report.colors[:lime] if filter == "page_view_anon"
|
|
color = report.colors[:purple] if filter == "page_view_crawler"
|
|
|
|
{
|
|
req: filter,
|
|
label: I18n.t("reports.consolidated_page_views.xaxis.#{filter}"),
|
|
color: color,
|
|
data: ApplicationRequest.where(req_type: ApplicationRequest.req_types[filter]),
|
|
}
|
|
end
|
|
|
|
requests.each do |request|
|
|
request[:data] = request[:data]
|
|
.where("date >= ? AND date <= ?", report.start_date, report.end_date)
|
|
.order(date: :asc)
|
|
.group(:date)
|
|
.sum(:count)
|
|
.map { |date, count| { x: date, y: count } }
|
|
end
|
|
|
|
report.data = requests
|
|
end
|
|
end
|
|
end
|