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

Fix loading bug on anomalies live chart #129

Merged
merged 2 commits into from
May 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Can you help check if other places have similar issue? Like detector list page?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked - detector list page doesn't ping anomaly results idx

let latestSingleLiveAnomalyResult = [] as any[];
try {
latestSingleLiveAnomalyResult = await getLatestAnomalyResultsByTimeRange(
searchES,
'30m',
dispatch,
-1,
1,
true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if you change this to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't that change the functionality of the call? I think we just want to encapsulate any error here (which can definitely be caused by the index not existing yet) and set is loading to false.

);
} catch (err) {
console.log('Error getting latest anomaly results - index may not exist yet', err);
setIsLoadingAnomalies(false);
}

setHasLatestAnomalyResult(!isEmpty(latestSingleLiveAnomalyResult));

Expand Down