Refined apply conditions
This commit is contained in:
@@ -1,26 +1,32 @@
|
||||
def applyConditions(definition, outputs):
|
||||
def applyConditions(definition, dictionary):
|
||||
if hasattr(definition, "filters"):
|
||||
print("DEBUG DICTIONARY PASS")
|
||||
print(dictionary)
|
||||
for filter in definition.filters:
|
||||
print("DEBUG applyConditons filter item consumption")
|
||||
print(outputs["event"])
|
||||
|
||||
item = outputs["event"]
|
||||
|
||||
#current_value = item[filter["filterkey"]]
|
||||
|
||||
if filter["operator"] == ">=":
|
||||
if item[filter["filterkey"]] >= filter["filtervalue"]:
|
||||
print("Applying filters")
|
||||
if dictionary.get(filter["filterkey"]) >= filter["filtervalue"]:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
if filter["operator"] == "<=":
|
||||
if dictionary.get(filter["filterkey"]) <= filter["filtervalue"]:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
if filter["operator"] == "==":
|
||||
if item[filter["filterkey"]] == filter["filtervalue"]:
|
||||
print("Applying filters")
|
||||
if dictionary.get(filter["filterkey"]) == filter["filtervalue"]:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
if filter["operator"] == "!=":
|
||||
if dictionary.get(filter["filterkey"]) != filter["filtervalue"]:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
if filter["operator"] == "in":
|
||||
if filter["filtervalue"] in outputs[filter["filterkey"]]:
|
||||
print("Applying filters")
|
||||
if filter["filtervalue"] in dictionary:
|
||||
print(filter["print"])
|
||||
return True
|
||||
|
||||
return False
|
||||
Reference in New Issue
Block a user