Use generic meta variable for returning more data about the search
This commit is contained in:
@@ -292,7 +292,7 @@ class NotificationRuleData(object):
|
||||
if not response:
|
||||
# No results in the result_map
|
||||
self.rule_no_match()
|
||||
for index, (aggs, results) in response.items():
|
||||
for index, (meta, results) in response.items():
|
||||
if not results:
|
||||
# Falsy results, no matches
|
||||
self.rule_not_matched(index)
|
||||
@@ -300,15 +300,17 @@ class NotificationRuleData(object):
|
||||
# Add the match values of all aggregations to a list
|
||||
aggs_for_index = []
|
||||
for agg_name in self.aggs.keys():
|
||||
if agg_name in aggs:
|
||||
if "match" in aggs[agg_name]:
|
||||
aggs_for_index.append(aggs[agg_name]["match"])
|
||||
if agg_name in meta["aggs"]:
|
||||
if "match" in meta["aggs"][agg_name]:
|
||||
aggs_for_index.append(meta["aggs"][agg_name]["match"])
|
||||
|
||||
# All required aggs are present
|
||||
if len(aggs_for_index) == len(self.aggs.keys()):
|
||||
if all(aggs_for_index):
|
||||
# All aggs have matched
|
||||
self.rule_matched(index, results[: self.object.amount], aggs)
|
||||
self.rule_matched(
|
||||
index, results[: self.object.amount], meta["aggs"]
|
||||
)
|
||||
continue
|
||||
# Default branch, since the happy path has a continue keyword
|
||||
self.rule_no_match(index)
|
||||
@@ -536,7 +538,7 @@ class NotificationRuleData(object):
|
||||
try:
|
||||
self.parsed = load(self.data, Loader=Loader)
|
||||
except (ScannerError, ParserError) as e:
|
||||
raise RuleParseError("data", f"Invalid YAML: {e}")
|
||||
raise RuleParseError(f"Invalid YAML: {e}", "data")
|
||||
|
||||
def __str__(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user