Skip to content

Commit

Permalink
avoid infinite ML rule config refetching
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpn committed Nov 1, 2024
1 parent c05a098 commit 7cf4857
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,22 @@ export function AlertSuppressionEditAdapter({
esqlQuery: 'esql_query' in finalDiffableRule ? finalDiffableRule.esql_query.query : undefined,
indexPatternsFields: dataView.fields,
});
const machineLearningJobId =
'machine_learning_job_id' in finalDiffableRule
? [finalDiffableRule.machine_learning_job_id].flat()
: [];
const machineLearningJobIds = useMemo(
() =>
'machine_learning_job_id' in finalDiffableRule
? [finalDiffableRule.machine_learning_job_id].flat()
: [],
[finalDiffableRule]
);
const {
mlSuppressionFields,
loading: mlRuleConfigLoading,
allJobsStarted,
} = useMLRuleConfig({
machineLearningJobId,
machineLearningJobId: machineLearningJobIds,
});
const isMlSuppressionIncomplete =
isMlRule(finalDiffableRule.type) && machineLearningJobId.length > 0 && !allJobsStarted;
isMlRule(finalDiffableRule.type) && machineLearningJobIds.length > 0 && !allJobsStarted;

const suppressibleFieldSpecs = useMemo(() => {
if (isEsqlRule(finalDiffableRule.type)) {
Expand Down

0 comments on commit 7cf4857

Please sign in to comment.