diff --git a/bucketing-lib.debug.wasm b/bucketing-lib.debug.wasm index dd83ce95..ea430a10 100644 Binary files a/bucketing-lib.debug.wasm and b/bucketing-lib.debug.wasm differ diff --git a/bucketing-lib.release.wasm b/bucketing-lib.release.wasm index 2e75cf99..3b534e45 100644 Binary files a/bucketing-lib.release.wasm and b/bucketing-lib.release.wasm differ diff --git a/bucketing/segmentation.go b/bucketing/segmentation.go index b3ef9923..659375cd 100644 --- a/bucketing/segmentation.go +++ b/bucketing/segmentation.go @@ -262,6 +262,16 @@ func _checkNumberFilter(num float64, filterNums []float64, operator string) bool return false } + if operator == "!=" { + passesFilter := true + for _, filterNum := range filterNums { + if math.IsNaN(filterNum) || num == filterNum { + passesFilter = false + } + } + return passesFilter + } + // replace filterNums.some() logic someValue := false for _, filterNum := range filterNums { @@ -271,8 +281,6 @@ func _checkNumberFilter(num float64, filterNums []float64, operator string) bool if operator == "=" { someValue = num == filterNum - } else if operator == "!=" { - someValue = num != filterNum } else if operator == ">" { someValue = num > filterNum } else if operator == ">=" { diff --git a/bucketing/segmentation_test.go b/bucketing/segmentation_test.go index de42aaab..c34c9329 100644 --- a/bucketing/segmentation_test.go +++ b/bucketing/segmentation_test.go @@ -1025,7 +1025,7 @@ func TestEvaluateOperator_MultiNotEqualCustomDataFilters(t *testing.T) { SubType: "customData", Comparator: ComparatorNotEqual, }, - Values: []interface{}{float64(0)}, + Values: []interface{}{float64(0), float64(1)}, }, DataKey: "numKey", DataKeyType: "Number", @@ -1416,7 +1416,8 @@ func Test_CheckNumberFilter(t *testing.T) { {num: 10, filterNums: []float64{15}, operator: "<=", want: true}, {num: 10, filterNums: []float64{5, 15}, operator: "!=", want: true}, - {num: 10, filterNums: []float64{}, operator: "!=", want: false}, + {num: 15, filterNums: []float64{5, 15}, operator: "!=", want: false}, + {num: 10, filterNums: []float64{}, operator: "!=", want: true}, {num: 10, filterNums: []float64{math.NaN()}, operator: "!=", want: false}, {num: 10, filterNums: []float64{}, operator: "fakeop", want: false},