From f58d9f475180bd6ce5709fa2f8624672b3aee5f8 Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Wed, 16 Oct 2019 08:08:08 +0100 Subject: [PATCH] [ML] Fixing overview page max anomaly score (#48110) * [ML] Fixing overview page max anomaly score * removing unnecessary copy of maxScore --- .../anomaly_detection_panel/anomaly_detection_panel.tsx | 6 +++--- .../ml/server/models/results_service/results_service.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/legacy/plugins/ml/public/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx b/x-pack/legacy/plugins/ml/public/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx index 3517c86a6109f..90b5be2c25406 100644 --- a/x-pack/legacy/plugins/ml/public/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx +++ b/x-pack/legacy/plugins/ml/public/overview/components/anomaly_detection_panel/anomaly_detection_panel.tsx @@ -98,13 +98,13 @@ export const AnomalyDetectionPanel: FC = () => { return ml.results.getMaxAnomalyScore(group.jobIds, twentyFourHoursAgo, latestTimestamp); }); - const results = await Promise.all(promises.map(p => p.catch(() => undefined))); + const results = await Promise.all(promises); const tempGroups = { ...groupsObject }; // Check results for each group's promise index and update state Object.keys(scores).forEach(groupId => { const resultsIndex = scores[groupId] && scores[groupId].index; - scores[groupId] = resultsIndex !== undefined && results[resultsIndex]; - tempGroups[groupId].max_anomaly_score = resultsIndex !== undefined && results[resultsIndex]; + const { maxScore } = resultsIndex !== undefined && results[resultsIndex]; + tempGroups[groupId].max_anomaly_score = maxScore || undefined; }); setGroups(tempGroups); diff --git a/x-pack/legacy/plugins/ml/server/models/results_service/results_service.js b/x-pack/legacy/plugins/ml/server/models/results_service/results_service.js index 3fd20308b2f9b..9501389af195d 100644 --- a/x-pack/legacy/plugins/ml/server/models/results_service/results_service.js +++ b/x-pack/legacy/plugins/ml/server/models/results_service/results_service.js @@ -264,7 +264,7 @@ export function resultsServiceProvider(callWithRequest) { const resp = await callWithRequest('search', query); const maxScore = _.get(resp, ['aggregations', 'max_score', 'value'], null); - return maxScore; + return { maxScore }; } // Obtains the latest bucket result timestamp by job ID.