Skip to content

Commit

Permalink
fix(ui): TE-2635 fix chart load issue on date change in alert details
Browse files Browse the repository at this point in the history
  • Loading branch information
nalin-patidar committed Jan 24, 2025
1 parent bb32e82 commit 2b7ae69
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ export const AlertsViewPage: FunctionComponent = () => {
retryNumber: number,
prevInterval?: NodeJS.Timeout
): Promise<void> => {
// let taskSubType: TaskSubtype | undefined;
// if (searchParams.get("update")) {
// taskSubType = TaskSubtype.DETECTION_HISTORICAL_DATA_AFTER_UPDATE;
// } else if (searchParams.has(QUERY_PARAM_KEY_ANOMALIES_RETRY)) {
// taskSubType = TaskSubtype.DETECTION_HISTORICAL_DATA_AFTER_CREATE;
// }
clearInterval(prevInterval);
if (
searchParams.get("alert") ||
Expand All @@ -136,7 +130,6 @@ export const AlertsViewPage: FunctionComponent = () => {
try {
setTaskStatusLoading(true);
const taskStatus = await getTasks({
// taskSubType: taskSubType,
alertOrSubGroupId: Number(alertId),
status: [TaskStatus.RUNNING, TaskStatus.WAITING],
});
Expand All @@ -156,13 +149,13 @@ export const AlertsViewPage: FunctionComponent = () => {
);
}, 5000 * Math.pow(2, retryNumber));
} else {
// setRefreshAttempts(0);
setTaskStatusLoading(false);
getAlertQuery.refetch();
getEnumerationItemsQuery.refetch();
getAnomaliesQuery.refetch();
getAlertInsight({ alertId: Number(alertId) });
fetchStats();
setNextAttemptTime(0);
}
} catch (e) {
setTaskStatusLoading(false);
Expand All @@ -181,6 +174,7 @@ export const AlertsViewPage: FunctionComponent = () => {
getAnomaliesQuery.refetch();
getAlertInsight({ alertId: Number(alertId) });
fetchStats();
setNextAttemptTime(0);
}
};

Expand All @@ -202,15 +196,13 @@ export const AlertsViewPage: FunctionComponent = () => {
queryFn: () => {
return getAlert(Number(alertId));
},
// enabled: false,
});

const getEnumerationItemsQuery = useFetchQuery({
queryKey: ["enumerationItems", alertId],
queryFn: () => {
return getEnumerationItems({ alertId: Number(alertId) });
},
// enabled: false,
});

const getAnomaliesQuery = useFetchQuery({
Expand All @@ -225,6 +217,16 @@ export const AlertsViewPage: FunctionComponent = () => {
enabled: false,
});

const handleRefetchAnomalies = (): void => {
getAnomaliesQuery.refetch();
};

useEffect(() => {
if (nextAttemptTime === 0) {
handleRefetchAnomalies();
}
}, [startTime, endTime]);

const [searchTerm, sortOrder, sortKey] = useMemo(
() => [
searchParams.get(QUERY_PARAM_KEY_FOR_SEARCH),
Expand Down

0 comments on commit 2b7ae69

Please sign in to comment.