bugfixing
This commit is contained in:
parent
fb0f3de1c4
commit
b90952df92
@ -170,8 +170,8 @@ function createRuleCheck(rule, ruleName, ruleValue) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to other numeric conditions
|
// Fallback to other numeric conditions
|
||||||
return (item) => {
|
return (item) => {
|
||||||
const itemValue = item[rule.name];
|
const itemValue = item[rule.name];
|
||||||
if (typeof ruleValue === 'string') return true; // Handle cases where the rule value is a string but not 'sentiment' or 'option_type'
|
if (typeof ruleValue === 'string') return true; // Handle cases where the rule value is a string but not 'sentiment' or 'option_type'
|
||||||
|
|
||||||
@ -180,11 +180,25 @@ function createRuleCheck(rule, ruleName, ruleValue) {
|
|||||||
const numericItemValue = parseFloat(itemValue);
|
const numericItemValue = parseFloat(itemValue);
|
||||||
if (isNaN(numericItemValue)) return false;
|
if (isNaN(numericItemValue)) return false;
|
||||||
|
|
||||||
|
// Handle 'between' condition for numeric fields using convertUnitToValue
|
||||||
|
if (rule.condition === 'between' && Array.isArray(ruleValue)) {
|
||||||
|
const [minValue, maxValue] = ruleValue.map(convertUnitToValue);
|
||||||
|
|
||||||
|
if (minValue === null && maxValue === null) return true;
|
||||||
|
if (minValue === null) return numericItemValue <= maxValue;
|
||||||
|
if (maxValue === null) return numericItemValue >= minValue;
|
||||||
|
|
||||||
|
return numericItemValue >= minValue && numericItemValue <= maxValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Existing conditions
|
||||||
if (rule.condition === 'over' && numericItemValue <= ruleValue) return false;
|
if (rule.condition === 'over' && numericItemValue <= ruleValue) return false;
|
||||||
if (rule.condition === 'under' && numericItemValue >= ruleValue) return false;
|
if (rule.condition === 'under' && numericItemValue >= ruleValue) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user