Skip to content

Commit

Permalink
Merge pull request #18 from certego/equal_bug_fix
Browse files Browse the repository at this point in the history
fixed result output, equal filter, customers
  • Loading branch information
ManofWax committed Feb 21, 2024
2 parents 6277cee + 15ba0d6 commit 112d458
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## 2.2.x
### 2.2.2
#### Bugfix
* Fixed result output
* Fixed customer stream type
* Fixed equal filter
### 2.2.1
#### Bugfix
* Fixed bug in *match()* method of *Routing* class
Expand Down
4 changes: 2 additions & 2 deletions routingfilter/filters/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ def match(self, event: DictQuery):
"""
filter_value = []
for value in self._value:
value = value.lower() if isinstance(value, str) else value
value = value.lower() if isinstance(value, str) else str(value)
filter_value.append(value)
for key in self._key:
event_value = event.get(key, [])
event_value = event_value if isinstance(event_value, list) else [event_value]
for value in event_value:
value = value.lower() if isinstance(value, str) else value
value = value.lower() if isinstance(value, str) else str(value)
if value in filter_value:
return True
return False
Expand Down
4 changes: 2 additions & 2 deletions routingfilter/filters/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Results:

def __init__(self, rules, output):
self.rules = rules
self.output = output
self.output = output["customer"] if output is not None and "customer" in output.keys() else output

def to_dict(self):
return {"output": self.output, "rules_uid": self.rules}
return {"output": self.output, "rules": self.rules}
4 changes: 2 additions & 2 deletions routingfilter/routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def load_from_dicts(self, rules_list: List[dict], validate_rules: bool = True, v
# check stream
if stream_type == "streams":
streams = self.streams
elif stream_type == "customer":
elif stream_type == "customers":
streams = self.customer
else:
self.logger.error(f"Error during loading rule. Invalid Stream: {stream_type}")
Expand All @@ -115,7 +115,7 @@ def load_from_dicts(self, rules_list: List[dict], validate_rules: bool = True, v
streams.add_rulemanager(rule_manager)
for rule in rule_file[stream_type]["rules"][tag]:
# add rule to rule manager and filters to rule
output = rule["streams"] if "streams" in rule.keys() else None
output = rule[stream_type] if stream_type in rule.keys() else None
if "id" not in rule.keys():
rule["id"] = str(uuid.uuid4())
uid = rule["id"]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="routingfilter",
version="2.2.1",
version="2.2.2",
packages=find_packages(include=["routingfilter", "routingfilter.*"]),
include_package_data=True,
install_requires=["IPy~=1.1", "macaddress~=2.0.2"],
Expand Down
4 changes: 2 additions & 2 deletions test_data/test_rule_3_customer_equals.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"customer": {
"customers": {
"rules": {
"all": [
{
Expand All @@ -15,7 +15,7 @@
]
}
],
"streams": {
"customer": {
"Workshop": {
"workers_needed": 1
}
Expand Down

0 comments on commit 112d458

Please sign in to comment.