Use cachalot to invalidate caches
This commit is contained in:
parent
9fcf5041f0
commit
4ead6ff7c1
|
@ -44,6 +44,7 @@ INSTALLED_APPS = [
|
||||||
"django_tables2_bulma_template",
|
"django_tables2_bulma_template",
|
||||||
"prettyjson",
|
"prettyjson",
|
||||||
"mixins",
|
"mixins",
|
||||||
|
"cachalot",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Performance optimisations
|
# Performance optimisations
|
||||||
|
@ -181,6 +182,7 @@ DEBUG_TOOLBAR_PANELS = [
|
||||||
"debug_toolbar.panels.logging.LoggingPanel",
|
"debug_toolbar.panels.logging.LoggingPanel",
|
||||||
"debug_toolbar.panels.redirects.RedirectsPanel",
|
"debug_toolbar.panels.redirects.RedirectsPanel",
|
||||||
"debug_toolbar.panels.profiling.ProfilingPanel",
|
"debug_toolbar.panels.profiling.ProfilingPanel",
|
||||||
|
"cachalot.panels.CachalotPanel",
|
||||||
]
|
]
|
||||||
|
|
||||||
from app.local_settings import * # noqa
|
from app.local_settings import * # noqa
|
||||||
|
|
|
@ -214,15 +214,6 @@ 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.
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load cache %}
|
{% load cache %}
|
||||||
|
{% load cachalot cache %}
|
||||||
{% cache 600 objects_plans request.user.id plans %}
|
{% get_last_invalidation 'core.Plan' as last %}
|
||||||
|
{% cache 600 objects_plans request.user.id plans last %}
|
||||||
{% for plan in plans %}
|
{% for plan in plans %}
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<article class="media">
|
<article class="media">
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
{% load cache %}
|
{% load cache %}
|
||||||
|
{% load cachalot cache %}
|
||||||
|
{% get_last_invalidation 'core.NotificationRule' as last %}
|
||||||
{% include 'mixins/partials/notify.html' %}
|
{% include 'mixins/partials/notify.html' %}
|
||||||
{% cache 600 objects_rules request.user.id object_list %}
|
{% cache 600 objects_rules request.user.id object_list last %}
|
||||||
<table
|
<table
|
||||||
class="table is-fullwidth is-hoverable"
|
class="table is-fullwidth is-hoverable"
|
||||||
hx-target="#{{ context_object_name }}-table"
|
hx-target="#{{ context_object_name }}-table"
|
||||||
|
@ -18,7 +20,6 @@
|
||||||
<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 %}
|
||||||
|
@ -42,7 +43,6 @@
|
||||||
{% 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
|
||||||
|
|
|
@ -25,3 +25,4 @@ git+https://git.zm.is/XF/django-crud-mixins
|
||||||
# For caching
|
# For caching
|
||||||
redis
|
redis
|
||||||
hiredis
|
hiredis
|
||||||
|
django-cachalot
|
||||||
|
|
Loading…
Reference in New Issue