[ML] Ensure charts loaded in Anomaly Explorer match swimlane selection (#23690)

* Only consider last request.Prevent promise race condition

* Reminder for regression test
This commit is contained in:
Melissa Alvarez 2018-10-03 11:19:20 +01:00 committed by GitHub
parent 57b4b144fc
commit 1311d89b24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,7 +48,11 @@ export function explorerChartsContainerServiceFactory(
callback(getDefaultData());
let requestCount = 0;
const anomalyDataChangeListener = function (anomalyRecords, earliestMs, latestMs) {
const newRequestCount = ++requestCount;
requestCount = newRequestCount;
const data = getDefaultData();
const threshold = mlSelectSeverityService.state.get('threshold');
@ -265,6 +269,11 @@ export function explorerChartsContainerServiceFactory(
Promise.all(seriesPromises)
.then(response => {
// TODO: Add test to prevent this regression.
// Ignore this response if it's returned by an out of date promise
if (newRequestCount < requestCount) {
return;
}
// calculate an overall min/max for all series
const processedData = response.map(processChartData);
const allDataPoints = _.reduce(processedData, (datapoints, series) => {