Skip to content

Commit

Permalink
Stats: hourly route for Odyssey and Calypso (#96746)
Browse files Browse the repository at this point in the history
* add hour route for Odyssey

* fix tests
  • Loading branch information
kangzj authored Nov 25, 2024
1 parent 8479302 commit ff4ed83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion apps/odyssey-stats/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ const redirectToSiteTrafficPage = () => {

export default function ( pageBase = '/' ) {
const validPeriods = [ 'day', 'week', 'month', 'year' ].join( '|' );
const validTrafficPagePeriods = [ 'hour', 'day', 'week', 'month', 'year' ].join( '|' );
const validEmailPeriods = [ 'hour', 'day' ].join( '|' );

const validModules = [
Expand Down Expand Up @@ -116,7 +117,7 @@ export default function ( pageBase = '/' ) {
statsPage( `/stats/subscribers/:period(${ validPeriods })/:site`, subscribers );

// Stat Site Pages
statsPage( `/stats/:period(${ validPeriods })/:site`, site );
statsPage( `/stats/:period(${ validTrafficPagePeriods })/:site`, site );

// Redirect this to default /stats/day/:module/:site view to
// keep the paths and page view reporting consistent.
Expand Down
5 changes: 3 additions & 2 deletions client/my-sites/stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const statsPage = ( url, controller ) => {
};

export default function () {
const validPeriods = [ 'hour', 'day', 'week', 'month', 'year' ].join( '|' );
const validPeriods = [ 'day', 'week', 'month', 'year' ].join( '|' );
const validTrafficPagePeriods = [ 'hour', 'day', 'week', 'month', 'year' ].join( '|' );
const validEmailPeriods = [ 'hour', 'day' ].join( '|' );

const validModules = [
Expand Down Expand Up @@ -64,7 +65,7 @@ export default function () {
statsPage( `/stats/subscribers/:period(${ validPeriods })/:site`, subscribers );

// Stat Site Pages
statsPage( `/stats/:period(${ validPeriods })/:site`, site );
statsPage( `/stats/:period(${ validTrafficPagePeriods })/:site`, site );

// Redirect this to default /stats/day/:module/:site view to
// keep the paths and page view reporting consistent.
Expand Down
6 changes: 3 additions & 3 deletions client/my-sites/stats/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ const validModules = [
'devices',
].join( '|' );

const validPeriods = [ 'hour', 'day', 'week', 'month', 'year' ].join( '|' );
const validPeriods = [ 'day', 'week', 'month', 'year' ].join( '|' );
const validTrafficPagePeriods = [ 'hour', 'day', 'week', 'month', 'year' ].join( '|' );

const routes = {
[ `/stats/:period(${ validPeriods })` ]: [
Expand All @@ -67,7 +68,7 @@ const routes = {
],
'/stats/insights': [ siteSelection, navigation, sites, makeLayout, clientRender ],
'/stats/insights/:site': [ siteSelection, navigation, insights, makeLayout, clientRender ],
[ `/stats/:period(${ validPeriods })/:site` ]: [
[ `/stats/:period(${ validTrafficPagePeriods })/:site` ]: [
siteSelection,
navigation,
site,
Expand All @@ -83,7 +84,6 @@ const routes = {
clientRender,
],
'/stats/post/:post_id/:site': [ siteSelection, navigation, post, makeLayout, clientRender ],

'/stats/page/:post_id/:site': [ siteSelection, navigation, post, makeLayout, clientRender ],
'/stats/follows/comment/:site': [ siteSelection, navigation, follows, makeLayout, clientRender ],
'/stats/follows/comment/:page_num/:site': [
Expand Down

0 comments on commit ff4ed83

Please sign in to comment.