Skip to content

Commit

Permalink
fix(ui): TE-2648 send entire alert in insight api req
Browse files Browse the repository at this point in the history
  • Loading branch information
nalin-patidar committed Feb 11, 2025
1 parent 8b7d79c commit 607b85d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const AlertViewSubHeader: FunctionComponent<AlertViewSubHeaderProps> = ({
const getAlertInsightQuery = useFetchQuery({
queryKey: ["alertInsight", alert.id],
queryFn: () => {
return getAlertInsight({ alertId: alert.id });
return getAlertInsight({ alert });
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ import {
useNotificationProviderV1,
} from "../../platform/components";
import { ActionStatus } from "../../rest/actions.interfaces";
import {
useGetAlertInsight,
useResetAlert,
} from "../../rest/alerts/alerts.actions";
import { useResetAlert } from "../../rest/alerts/alerts.actions";
import {
getAlert,
getAlertStats,
Expand Down Expand Up @@ -97,7 +94,6 @@ export const AlertsViewPage: FunctionComponent = () => {
useState<NotificationV1 | null>(null);
const [resetStatusNotification, setResetStatusNotification] =
useState<NotificationV1 | null>(null);
const { alertInsight, getAlertInsight } = useGetAlertInsight();
const [taskStatusLoading, setTaskStatusLoading] = useState(false);

const [searchParams, setSearchParams] = useSearchParams();
Expand Down Expand Up @@ -153,7 +149,6 @@ export const AlertsViewPage: FunctionComponent = () => {
getAlertQuery.refetch();
getEnumerationItemsQuery.refetch();
getAnomaliesQuery.refetch();
getAlertInsight({ alertId: Number(alertId) });
fetchStats();
setNextAttemptTime(0);
}
Expand All @@ -172,7 +167,6 @@ export const AlertsViewPage: FunctionComponent = () => {
getAlertQuery.refetch();
getEnumerationItemsQuery.refetch();
getAnomaliesQuery.refetch();
getAlertInsight({ alertId: Number(alertId) });
fetchStats();
setNextAttemptTime(0);
}
Expand Down Expand Up @@ -239,26 +233,6 @@ export const AlertsViewPage: FunctionComponent = () => {
[searchParams]
);

useEffect(() => {
getAlertInsight({ alertId: Number(alertId) });
}, []);

useEffect(() => {
if (
!alertInsight?.analysisRunInfo?.success &&
alertInsight?.analysisRunInfo?.message
) {
notifyIfErrors(
ActionStatus.Error,
[{ message: alertInsight.analysisRunInfo.message }],
notify,
t("message.error-while-fetching", {
entity: t("label.alert-insight"),
})
);
}
}, [alertInsight?.analysisRunInfo]);

const fetchStats = (): void => {
getAlertStats({
alertId: Number(alertId),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import {
TimeRangeQueryStringKey,
} from "../../../components/time-range/time-range-provider/time-range-provider.interfaces";
import { AppLoadingIndicatorV1 } from "../../../platform/components";
import { useGetAlertInsight } from "../../../rest/alerts/alerts.actions";
import {
useGetAlert,
useGetAlertInsight,
} from "../../../rest/alerts/alerts.actions";
import { useLastUsedSearchParams } from "../../../stores/last-used-params/last-used-search-params.store";
import { AlertFetchRedirectParamsProps } from "./alert-fetch-redirect-params.interfaces";

Expand All @@ -34,21 +37,24 @@ export const AlertFetchRedirectParams: FunctionComponent<AlertFetchRedirectParam
const [isLoading, setIsLoading] = useState(true);
const { id: alertId } = useParams();
const { alertInsight, getAlertInsight } = useGetAlertInsight();
const { alert, getAlert } = useGetAlert();
const location = useLocation();
const navigate = useNavigate();
const [searchParams] = useSearchParams();
const { getLastUsedForPath } = useLastUsedSearchParams();
let searchString: string | undefined;

useEffect(() => {
if (alertId) {
getAlertInsight({ alertId: Number(alertId) }).finally(() =>
getAlert(Number(alertId));
}, [alertId]);

useEffect(() => {
if (alert) {
getAlertInsight({ alert: alert }).finally(() =>
setIsLoading(false)
);
} else {
setIsLoading(false);
}
}, []);
}, [alert]);

useEffect(() => {
if (isLoading) {
Expand Down

0 comments on commit 607b85d

Please sign in to comment.