Fix window/interval validation and make aggs optional in parse_results
This commit is contained in:
parent
eb2486afba
commit
2dd9efcc6f
|
@ -58,7 +58,7 @@ def annotate_results(results):
|
||||||
item["num_chans"] = num_chans[item["nick"]]
|
item["num_chans"] = num_chans[item["nick"]]
|
||||||
|
|
||||||
|
|
||||||
def parse_results(results, aggs):
|
def parse_results(results, aggs=None):
|
||||||
results_parsed = []
|
results_parsed = []
|
||||||
stringify = ["host", "channel"]
|
stringify = ["host", "channel"]
|
||||||
if "hits" in results.keys():
|
if "hits" in results.keys():
|
||||||
|
|
|
@ -104,9 +104,9 @@ class NotificationRuleForm(RestrictedFormMixin, ModelForm):
|
||||||
"interval",
|
"interval",
|
||||||
"window",
|
"window",
|
||||||
"priority",
|
"priority",
|
||||||
"service",
|
|
||||||
"url",
|
|
||||||
"topic",
|
"topic",
|
||||||
|
"url",
|
||||||
|
"service",
|
||||||
"enabled",
|
"enabled",
|
||||||
)
|
)
|
||||||
help_texts = {
|
help_texts = {
|
||||||
|
|
|
@ -22,6 +22,9 @@ def raw_sendmsg(msg, title=None, priority=None, tags=None, url=None, topic=None)
|
||||||
data=msg,
|
data=msg,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
)
|
)
|
||||||
|
print("Sent notification to", url)
|
||||||
|
print("topic", topic)
|
||||||
|
print("msg", msg)
|
||||||
except requests.exceptions.ConnectionError as e:
|
except requests.exceptions.ConnectionError as e:
|
||||||
log.error(f"Error sending notification: {e}")
|
log.error(f"Error sending notification: {e}")
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ class NotificationRuleData(object):
|
||||||
"Window cannot be specified with on-demand interval", "window"
|
"Window cannot be specified with on-demand interval", "window"
|
||||||
)
|
)
|
||||||
|
|
||||||
if interval is not None and window is None:
|
if interval != 0 and window is None:
|
||||||
raise RuleParseError(
|
raise RuleParseError(
|
||||||
"Window must be specified with non-on-demand interval", "window"
|
"Window must be specified with non-on-demand interval", "window"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue