Skip to content

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

FEATURE: Show legacy pageview report for sites using legacy pageviews (#33620)

Linca22e4014b2fd1
diff --git a/app/assets/javascripts/admin/addon/routes/admin-reports-show.js b/app/assets/javascripts/admin/addon/routes/admin-reports-show.js
index acfd515b3ba..6f20802a591 100644
--- a/app/assets/javascripts/admin/addon/routes/admin-reports-show.js
+++ b/app/assets/javascripts/admin/addon/routes/admin-reports-show.js
@@ -56,6 +56,20 @@ export default class AdminReportsShowRoute extends DiscourseRoute {
return super.serializeQueryParam(value, urlKey, defaultValueType);
}
+ redirect(params) {
+ if (
+ params.type === "site_traffic" &&
+ this.siteSettings.use_legacy_pageviews
+ ) {
+ this.router.transitionTo("adminReports.show", "consolidated_page_views", {
+ queryParams: {
+ ...params,
+ type: "consolidated_page_views",
+ },
+ });
+ }
+ }
+
@action
onParamsChange(params) {
const queryParams = {
diff --git a/spec/system/admin_reports_spec.rb b/spec/system/admin_reports_spec.rb
new file mode 100644
index 00000000000..f198980ed98
--- /dev/null
+++ b/spec/system/admin_reports_spec.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+describe "Admin Reports", type: :system do
+ fab!(:current_user, :admin)
+ before { sign_in(current_user) }
+
+ context "when use_legacy_pageviews is true" do
+ before { SiteSetting.use_legacy_pageviews = true }
+
+ it "redirects from site_traffic to consolidated_page_views" do
+ visit "/admin/reports/site_traffic"
+ expect(page).to have_current_path("/admin/reports/consolidated_page_views")
+ end
+ end
+
+ context "when use_legacy_pageviews is false" do
+ before { SiteSetting.use_legacy_pageviews = false }
+
+ it "won't redirects from site_traffic to consolidated_page_views" do
+ visit "/admin/reports/site_traffic"
+ expect(page).to have_current_path("/admin/reports/site_traffic")
+ end
+ end
+end