Properly handle matched and meta fields, always return sentiment aggregations

This commit is contained in:
2023-02-09 21:41:00 +00:00
parent c67d89c978
commit f4273e4453
2 changed files with 17 additions and 8 deletions

View File

@@ -291,11 +291,12 @@ class NotificationRuleData(object):
"""
new_aggs = {}
for agg_name, agg in aggs.items():
print("ITER", agg_name, agg)
# Already checked membership below
op, value = self.aggs[agg_name]
new_aggs[agg_name] = f"{agg['value']}{op}{value}"
return
return new_aggs
def reform_matches(self, index, matches, meta, mode):
if not isinstance(matches, list):
@@ -362,6 +363,7 @@ class NotificationRuleData(object):
# We hit the return above if we don't need to notify
if "aggs" in meta and "matched" not in meta:
meta["matched"] = self.format_aggs(meta["aggs"])
print("MATCHED", meta["matched"])
rule_notify(self.object, index, message, meta)
self.store_match(index, message)
await self.ingest_matches(index, message, meta, mode)
@@ -545,7 +547,10 @@ class NotificationRuleData(object):
)
if self.policy != "default":
raise RuleParseError(
f"Cannot use {self.cleaned_data['policy']} policy with on-demand rules",
(
f"Cannot use {self.cleaned_data['policy']} policy with "
"on-demand rules"
),
"policy",
)