From 691bfd99b3e92c7eebb2827d73bed779641f698f Mon Sep 17 00:00:00 2001 From: Jasper Kang Date: Tue, 26 Nov 2024 12:46:42 +1300 Subject: [PATCH] redirect hourly to daily for summary pages (#96751) --- apps/odyssey-stats/src/routes.ts | 3 +++ client/my-sites/stats/controller.jsx | 6 ++++++ client/my-sites/stats/index.js | 3 +++ 3 files changed, 12 insertions(+) diff --git a/apps/odyssey-stats/src/routes.ts b/apps/odyssey-stats/src/routes.ts index a13fff79c914dc..87a7dcb515efcc 100644 --- a/apps/odyssey-stats/src/routes.ts +++ b/apps/odyssey-stats/src/routes.ts @@ -15,6 +15,7 @@ import { purchase, emailStats, emailSummary, + redirectToDaySummary, } from 'calypso/my-sites/stats/controller'; import { SITE_REQUEST, @@ -125,6 +126,8 @@ export default function ( pageBase = '/' ) { // Stat Summary Pages statsPage( `/stats/:period(${ validPeriods })/:module(${ validModules })/:site`, summary ); + // No hourly stats for modules + statsPage( `/stats/hour/:module(${ validModules })/:site`, redirectToDaySummary ); // Stat Single Post Page statsPage( '/stats/post/:post_id/:site', post ); diff --git a/client/my-sites/stats/controller.jsx b/client/my-sites/stats/controller.jsx index 5187e6b84e2ad3..010a7ff59edc28 100644 --- a/client/my-sites/stats/controller.jsx +++ b/client/my-sites/stats/controller.jsx @@ -225,6 +225,12 @@ export function site( context, next ) { next(); } +export function redirectToDaySummary( context ) { + page.redirect( + `/stats/day/${ context.params.module }/${ context.params.site }${ window.location.search }` + ); +} + export function summary( context, next ) { let siteId = context.params.site; const siteFragment = getSiteFragment( context.path ); diff --git a/client/my-sites/stats/index.js b/client/my-sites/stats/index.js index 94fbf6f9c1d76b..05b2c3bba5bab2 100644 --- a/client/my-sites/stats/index.js +++ b/client/my-sites/stats/index.js @@ -17,6 +17,7 @@ import { emailSummary, subscribers, purchase, + redirectToDaySummary, } from './controller'; import './style.scss'; @@ -73,6 +74,8 @@ export default function () { // Stat Summary Pages statsPage( `/stats/:period(${ validPeriods })/:module(${ validModules })/:site`, summary ); + // No hourly stats for modules + statsPage( `/stats/hour/:module(${ validModules })/:site`, redirectToDaySummary ); // Stat Single Post Page statsPage( '/stats/post/:post_id/:site', post );