Merge pull request woocommerce/woocommerce-admin#2785 from woocommerce/fix/2775-long-time-scale-chart-render

Wait until all chart data page requests are complete before rendering.
This commit is contained in:
Jeff Stieler 2019-08-14 07:59:22 -07:00 committed by GitHub
commit 1b9f3ed0b3
1 changed files with 4 additions and 1 deletions

View File

@ -274,6 +274,7 @@ export function getReportChartData( options ) {
let isError = false;
const pagedData = [];
const totalPages = Math.ceil( stats.totalResults / MAX_PER_PAGE );
let pagesFetched = 1;
for ( let i = 2; i <= totalPages; i++ ) {
const nextQuery = { ...requestQuery, page: i };
@ -288,7 +289,9 @@ export function getReportChartData( options ) {
}
pagedData.push( _data );
if ( i === totalPages ) {
pagesFetched++;
if ( pagesFetched === totalPages ) {
isFetching = false;
break;
}