From e222fa64e0c5da6a8e2ba15ba98df842d7ea6b8e Mon Sep 17 00:00:00 2001 From: Pete Harverson Date: Fri, 5 Apr 2019 17:01:16 +0100 Subject: [PATCH] [ML] Only update forecasting progress bar if value increases (#34614) --- .../forecasting_modal/forecasting_modal.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ml/public/timeseriesexplorer/components/forecasting_modal/forecasting_modal.js b/x-pack/plugins/ml/public/timeseriesexplorer/components/forecasting_modal/forecasting_modal.js index c72efd5c5fa0..2ac92b626728 100644 --- a/x-pack/plugins/ml/public/timeseriesexplorer/components/forecasting_modal/forecasting_modal.js +++ b/x-pack/plugins/ml/public/timeseriesexplorer/components/forecasting_modal/forecasting_modal.js @@ -223,7 +223,14 @@ export const ForecastingModal = injectI18n(class ForecastingModal extends Compon const progress = _.get(resp, ['stats', 'forecast_progress'], previousProgress); const status = _.get(resp, ['stats', 'forecast_status']); - this.setState({ forecastProgress: Math.round(100 * progress) }); + // The requests for forecast stats can get routed to different shards, + // and if these operate at different speeds there is a chance that a + // previous request could arrive later. + // The progress reported by the back-end should never go down, so + // to be on the safe side, only update state if progress has increased. + if (progress > previousProgress) { + this.setState({ forecastProgress: Math.round(100 * progress) }); + } // Display any messages returned in the request stats. let messages = _.get(resp, ['stats', 'forecast_messages'], []); @@ -286,7 +293,12 @@ export const ForecastingModal = injectI18n(class ForecastingModal extends Compon } } else { - previousProgress = progress; + if (progress > previousProgress) { + previousProgress = progress; + } + + // Reset the 'no progress' check value. + noProgressMs = 0; } }