From 2dd9efcc6f0e285182af34843b49267f6165d3e5 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sun, 15 Jan 2023 20:27:19 +0000 Subject: [PATCH] Fix window/interval validation and make aggs optional in parse_results --- core/db/processing.py | 2 +- core/forms.py | 4 ++-- core/lib/notify.py | 3 +++ core/lib/rules.py | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/db/processing.py b/core/db/processing.py index 25a36b0..11b1656 100644 --- a/core/db/processing.py +++ b/core/db/processing.py @@ -58,7 +58,7 @@ def annotate_results(results): item["num_chans"] = num_chans[item["nick"]] -def parse_results(results, aggs): +def parse_results(results, aggs=None): results_parsed = [] stringify = ["host", "channel"] if "hits" in results.keys(): diff --git a/core/forms.py b/core/forms.py index 7447613..98a1a5d 100644 --- a/core/forms.py +++ b/core/forms.py @@ -104,9 +104,9 @@ class NotificationRuleForm(RestrictedFormMixin, ModelForm): "interval", "window", "priority", - "service", - "url", "topic", + "url", + "service", "enabled", ) help_texts = { diff --git a/core/lib/notify.py b/core/lib/notify.py index 89291ec..d63a001 100644 --- a/core/lib/notify.py +++ b/core/lib/notify.py @@ -22,6 +22,9 @@ def raw_sendmsg(msg, title=None, priority=None, tags=None, url=None, topic=None) data=msg, headers=headers, ) + print("Sent notification to", url) + print("topic", topic) + print("msg", msg) except requests.exceptions.ConnectionError as e: log.error(f"Error sending notification: {e}") diff --git a/core/lib/rules.py b/core/lib/rules.py index a53e916..a599640 100644 --- a/core/lib/rules.py +++ b/core/lib/rules.py @@ -243,7 +243,7 @@ class NotificationRuleData(object): "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( "Window must be specified with non-on-demand interval", "window" )