From 6fe31d99a900110a3abc31d6b7951c92bbd5b002 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Sat, 11 Feb 2023 18:06:09 +0000 Subject: [PATCH] Re-add matches field --- core/models.py | 9 +++++++++ core/templates/partials/rule-list.html | 2 ++ 2 files changed, 11 insertions(+) diff --git a/core/models.py b/core/models.py index c76843f..9586fab 100644 --- a/core/models.py +++ b/core/models.py @@ -214,6 +214,15 @@ class NotificationRule(models.Model): raise ValueError(f"Invalid YAML: {e}") return parsed + @property + def matches(self): + """ + Get the total number of matches for this rule. + """ + if isinstance(self.match, dict): + truthy_values = [x for x in self.match.values() if x is not False] + return f"{len(truthy_values)}/{len(self.match)}" + def get_notification_settings(self, check=True): """ Get the notification settings for this rule. diff --git a/core/templates/partials/rule-list.html b/core/templates/partials/rule-list.html index 864013f..da15f16 100644 --- a/core/templates/partials/rule-list.html +++ b/core/templates/partials/rule-list.html @@ -20,6 +20,7 @@ topic enabled data length + match actions {% for item in object_list %} @@ -43,6 +44,7 @@ {% endif %} {{ item.data|length }} + {{ item.matches }}