-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stats: Pull minute data for Real-time Stats chart #99419
base: trunk
Are you sure you want to change the base?
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Async-loaded Components (~298 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
useEffect( () => { | ||
const intervalId = setInterval( () => { | ||
// Index the chart data by YYYY-MM-DD HH:mm:00. | ||
const adjustedDatetime = moment().utcOffset( gmtOffset ).format( 'YYYY-MM-DD HH:mm:00' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we able to reuse momentSiteZone
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it, but the current hour might not be accurate inside the setInterval
callback. I will test again if this approach works for minutes across the hour.
<div> | ||
<AsyncLoad | ||
require="calypso/my-sites/stats/components/line-chart" | ||
height={ 425 } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to the PR - the height is a little too much on mobile, so maybe we should do responsive for mobiles? 🤔
require="calypso/my-sites/stats/components/line-chart" | ||
height={ 425 } | ||
placeholder={ PageLoading } | ||
chartData={ [ { label: 'Views', options: { stroke: '#069e08' }, data: chartData } ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not related to the PR - Let's not forget Odyssey has a different set of colors.
} | ||
// TODO: Change to 60 for production. | ||
const UPDATE_INTERVAL_IN_SECONDS = 5; | ||
// TODO: Change to 30 after resolving the date format issue on the X-axis. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please share more about the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The series data passed to the line chart requires a date
attribute, which only accepts date objects. In this case, the tickFormat callback would also need to support simple strings, such as -10m
.
Another issue is that I assumed the chart's X-axis automatically combines labels from single minutes to about the unexpected 5 or 10 minutes if they are too crowded. However, this feature seems reasonable and might be addressed if the one above is supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the annotation to a626e61.
return () => clearInterval( intervalId ); | ||
}, [ siteId, gmtOffset ] ); | ||
|
||
let chartData = Object.keys( viewsData ).map( ( eachMinute ) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably memo this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in 2c0fff9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! Left a couple of comments but no blocker.
It'll be great to have @annacmc to take a look as well 😄
Related to https://github.com/Automattic/red-team/issues/335
Proposed Changes
RealtimeChart
component to query hourly data and process views difference by minute for the line chart.Why are these changes being made?
Testing Instructions
stats/real-time-tab
for a high-traffic site.Pre-merge Checklist