Skip to content

Commit

Permalink
redirect hourly to daily for summary pages (#96751)
Browse files Browse the repository at this point in the history
  • Loading branch information
kangzj authored Nov 25, 2024
1 parent 8146923 commit 691bfd9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions apps/odyssey-stats/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
purchase,
emailStats,
emailSummary,
redirectToDaySummary,
} from 'calypso/my-sites/stats/controller';
import {
SITE_REQUEST,
Expand Down Expand Up @@ -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 );
Expand Down
6 changes: 6 additions & 0 deletions client/my-sites/stats/controller.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
3 changes: 3 additions & 0 deletions client/my-sites/stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
emailSummary,
subscribers,
purchase,
redirectToDaySummary,
} from './controller';

import './style.scss';
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 691bfd9

Please sign in to comment.