Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Fix loading bug on anomalies live chart (#129)
Browse files Browse the repository at this point in the history
* Fix loading bug on live anomalies chart
  • Loading branch information
ohltyler committed May 11, 2020
1 parent c976bb1 commit 5c78364
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions public/pages/Dashboard/Components/AnomaliesLiveChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,22 @@ export const AnomaliesLiveChart = (props: AnomaliesLiveChartProps) => {
const getLiveAnomalyResults = async () => {
setIsLoadingAnomalies(true);
// check if there is any anomaly result in last 30mins
const latestSingleLiveAnomalyResult = await getLatestAnomalyResultsByTimeRange(
searchES,
'30m',
dispatch,
-1,
1,
true
);
// need to initially check if there is an error when accessing anomaly results index
// in the case that it doesn't exist upon cluster initialization
let latestSingleLiveAnomalyResult = [] as any[];
try {
latestSingleLiveAnomalyResult = await getLatestAnomalyResultsByTimeRange(
searchES,
'30m',
dispatch,
-1,
1,
true
);
} catch (err) {
console.log('Error getting latest anomaly results - index may not exist yet', err);
setIsLoadingAnomalies(false);
}

setHasLatestAnomalyResult(!isEmpty(latestSingleLiveAnomalyResult));

Expand Down

0 comments on commit 5c78364

Please sign in to comment.