Skip to content

Commit

Permalink
Fix IS_NOT_BETWEEN comparator for the custom threshold, Infra, Metric…
Browse files Browse the repository at this point in the history
… rules
  • Loading branch information
fkanout committed Nov 24, 2023
1 parent b2ca784 commit 307fe3f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const createConditionScript = (
}
if (comparator === Comparator.OUTSIDE_RANGE && threshold.length === 2) {
return {
source: `params.value < params.threshold0 && params.value > params.threshold1 ? 1 : 0`,
// OUTSIDE_RANGE/NOT BETWEEN is the opposite of BETWEEN. Use the BETWEEN condition and switch the 1 and 0
source: `params.value > params.threshold0 && params.value < params.threshold1 ? 0 : 1`,
params: {
threshold0: threshold[0],
threshold1: threshold[1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const createConditionScript = (threshold: number[], comparator: Comparato
}
if (comparator === Comparator.OUTSIDE_RANGE && threshold.length === 2) {
return {
source: `params.value < params.threshold0 && params.value > params.threshold1 ? 1 : 0`,
// OUTSIDE_RANGE/NOT BETWEEN is the opposite of BETWEEN. Use the BETWEEN condition and switch the 1 and 0
source: `params.value > params.threshold0 && params.value < params.threshold1 ? 0 : 1`,
params: {
threshold0: threshold[0],
threshold1: threshold[1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const createConditionScript = (threshold: number[], comparator: Comparato
}
if (comparator === Comparator.OUTSIDE_RANGE && threshold.length === 2) {
return {
source: `params.value < params.threshold0 && params.value > params.threshold1 ? 1 : 0`,
// OUTSIDE_RANGE/NOT BETWEEN is the opposite of BETWEEN. Use the BETWEEN condition and switch the 1 and 0
source: `params.value > params.threshold0 && params.value < params.threshold1 ? 0 : 1`,
params: {
threshold0: threshold[0],
threshold1: threshold[1],
Expand Down

0 comments on commit 307fe3f

Please sign in to comment.