2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-29 05:54:56 -04:00
|
|
|
Report.add_report("consolidated_page_views") do |report|
|
|
|
|
filters = %w[
|
|
|
|
page_view_logged_in
|
|
|
|
page_view_anon
|
|
|
|
page_view_crawler
|
|
|
|
]
|
|
|
|
|
|
|
|
report.modes = [:stacked_chart]
|
|
|
|
|
|
|
|
tertiary = ColorScheme.hex_for_name('tertiary') || '0088cc'
|
|
|
|
danger = ColorScheme.hex_for_name('danger') || 'e45735'
|
|
|
|
|
|
|
|
requests = filters.map do |filter|
|
|
|
|
color = report.rgba_color(tertiary)
|
|
|
|
|
|
|
|
if filter == "page_view_anon"
|
2019-05-07 12:14:13 -04:00
|
|
|
color = report.lighten_color(tertiary, 0.25)
|
2019-03-29 05:54:56 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
if filter == "page_view_crawler"
|
|
|
|
color = report.rgba_color(danger, 0.75)
|
|
|
|
end
|
|
|
|
|
|
|
|
{
|
|
|
|
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
|