mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 07:29:30 +08:00

### UI changes
All of the UI changes described are gated behind the `use_legacy_pageviews`
site setting.
This commit changes the admin dashboard pageviews report to
use the "Consolidated Pageviews with Browser Detection" report
introduced in 2f2da72747
with
the following changes:
* The report name is changed to "Site traffic"
* The pageview count on the dashboard is counting only using the new method
* The old "Consolidated Pageviews" report is renamed as "Consolidated Legacy Pageviews"
* By default "known crawlers" and "other" sources of pageviews are hidden on the report
When `use_legacy_pageviews` is `true`, we do not show or allow running
the "Site traffic" report for admins. When `use_legacy_pageviews` is `false`,
we do not show or allow running the following legacy reports:
* consolidated_page_views
* consolidated_page_views_browser_detection
* page_view_anon_reqs
* page_view_logged_in_reqs
### Historical data changes
Also part of this change is that, since we introduced our new "Consolidated
Pageviews with Browser Detection" report, some admins are confused at either:
* The lack of data before a certain date , which didn’t exist before
we started collecting it
* Comparing this and the current "Consolidated Pageviews" report data,
which rolls up "Other Pageviews" into "Anonymous Browser" and so it
appears inaccurate
All pageview data in the new report before the date where the _first_
anon or logged in browser pageview was recorded is now hidden.
41 lines
1.2 KiB
Ruby
41 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Reports::ConsolidatedPageViews
|
|
extend ActiveSupport::Concern
|
|
|
|
class_methods do
|
|
# NOTE: This report is deprecated, once use_legacy_pageviews is
|
|
# always false or no longer needed we can delete this.
|
|
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
|