Skip to content

Commit

Permalink
Fix mat chart if time grain is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
majakomel committed Feb 15, 2023
1 parent 0541f87 commit 5db15aa
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions pages/chart/mat.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,22 @@ const MeasurementAggregationToolkit = ({ testNames }) => {
// In that case, trigger a shallow navigation that shows a chart
useEffect(() => {
const { query } = router
if (Object.keys(query).length === 0) {
const today = dayjs.utc().add(1, 'day')
const monthAgo = dayjs.utc(today).subtract(1, 'month')
const href = {
query: {
test_name: 'web_connectivity',
axis_x: 'measurement_start_day',
since: monthAgo.format('YYYY-MM-DD'),
until: today.format('YYYY-MM-DD'),
time_grain: 'day',
},
}
router.replace(href, undefined, { shallow: true })
const today = dayjs.utc().add(1, 'day')
const monthAgo = dayjs.utc(today).subtract(1, 'month')
const href = {
query: {
test_name: 'web_connectivity',
axis_x: 'measurement_start_day',
since: monthAgo.format('YYYY-MM-DD'),
until: today.format('YYYY-MM-DD'),
time_grain: 'day',
...query
},
}
// Ignore the dependency on `router` because we want
// this effect to run only once, on mount, if query is empty.
// eslint-disable-next-line react-hooks/exhaustive-deps
router.replace(href, undefined, { shallow: true })
// Ignore the dependency on `router` because we want
// this effect to run only once, on mount, if query is empty.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

const shouldFetchData = router.pathname !== router.asPath
Expand Down

1 comment on commit 5db15aa

@vercel
Copy link

@vercel vercel bot commented on 5db15aa Feb 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

explorer – ./

explorer-one.vercel.app
explorer-git-master-ooni1.vercel.app
explorer-ooni1.vercel.app

Please sign in to comment.