Alerting: Fix getSimpleConditionFromExpressions (#94516)

fix getSimpleConditionFromExpressions
This commit is contained in:
Sonia Aguilar 2024-10-10 09:56:15 +02:00 committed by GitHub
parent 9ece88d585
commit 419598c745
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -218,11 +218,17 @@ export function getSimpleConditionFromExpressions(expressions: Array<AlertQuery<
(query) => query.model.type === ExpressionQueryType.threshold && query.refId === SIMPLE_CONDITION_THRESHOLD_ID
);
const conditionsFromThreshold = thresholdExpression?.model.conditions ?? [];
const whenField = reduceExpression?.model.reducer ?? ReducerID.last;
const params = conditionsFromThreshold[0]?.evaluator?.params
? [...conditionsFromThreshold[0]?.evaluator?.params]
: [0];
const type = conditionsFromThreshold[0]?.evaluator?.type ?? EvalFunction.IsAbove;
return {
whenField: reduceExpression?.model.reducer ?? ReducerID.last,
whenField: whenField,
evaluator: {
params: [...conditionsFromThreshold[0]?.evaluator?.params] ?? [0],
type: conditionsFromThreshold[0]?.evaluator?.type ?? EvalFunction.IsAbove,
params: params,
type: type,
},
};
}