Re-add matches field
This commit is contained in:
parent
1ab7a95ebd
commit
6fe31d99a9
|
@ -214,6 +214,15 @@ class NotificationRule(models.Model):
|
||||||
raise ValueError(f"Invalid YAML: {e}")
|
raise ValueError(f"Invalid YAML: {e}")
|
||||||
return parsed
|
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):
|
def get_notification_settings(self, check=True):
|
||||||
"""
|
"""
|
||||||
Get the notification settings for this rule.
|
Get the notification settings for this rule.
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
<th>topic</th>
|
<th>topic</th>
|
||||||
<th>enabled</th>
|
<th>enabled</th>
|
||||||
<th>data length</th>
|
<th>data length</th>
|
||||||
|
<th>match</th>
|
||||||
<th>actions</th>
|
<th>actions</th>
|
||||||
</thead>
|
</thead>
|
||||||
{% for item in object_list %}
|
{% for item in object_list %}
|
||||||
|
@ -43,6 +44,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ item.data|length }}</td>
|
<td>{{ item.data|length }}</td>
|
||||||
|
<td>{{ item.matches }}</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button
|
<button
|
||||||
|
|
Loading…
Reference in New Issue