Cache all object list templates

This commit is contained in:
Mark Veidemanis 2023-02-11 14:52:00 +00:00
parent 0acddb2048
commit a0c94b2097
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
16 changed files with 1000 additions and 967 deletions

View File

@ -68,6 +68,9 @@ CACHES = {
}, },
} }
} }
# CACHE_MIDDLEWARE_ALIAS = 'default'
# CACHE_MIDDLEWARE_SECONDS = '600'
# CACHE_MIDDLEWARE_KEY_PREFIX = ''
CRISPY_TEMPLATE_PACK = "bulma" CRISPY_TEMPLATE_PACK = "bulma"
CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",) CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",)
@ -77,16 +80,15 @@ MIDDLEWARE = [
"debug_toolbar.middleware.DebugToolbarMiddleware", "debug_toolbar.middleware.DebugToolbarMiddleware",
"django.middleware.security.SecurityMiddleware", "django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware", "django.contrib.sessions.middleware.SessionMiddleware",
# 'django.middleware.cache.UpdateCacheMiddleware',
"django.middleware.common.CommonMiddleware", "django.middleware.common.CommonMiddleware",
# 'django.middleware.cache.FetchFromCacheMiddleware',
"django.middleware.csrf.CsrfViewMiddleware", "django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django_otp.middleware.OTPMiddleware", "django_otp.middleware.OTPMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_htmx.middleware.HtmxMiddleware", "django_htmx.middleware.HtmxMiddleware",
# 'django.middleware.cache.UpdateCacheMiddleware',
# 'django.middleware.common.CommonMiddleware',
# 'django.middleware.cache.FetchFromCacheMiddleware',
] ]
ROOT_URLCONF = "app.urls" ROOT_URLCONF = "app.urls"

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_accounts request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -109,4 +110,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_assetgroups request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -69,4 +70,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_assetrestrictions request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -68,4 +69,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_callbacks request.user.id object_list %}
<table class="table is-fullwidth is-hoverable" id="callbacks-table"> <table class="table is-fullwidth is-hoverable" id="callbacks-table">
<thead> <thead>
<th>id</th> <th>id</th>
<th>hook id</th> <th>hook id</th>
@ -47,4 +48,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_hooks request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -89,4 +90,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,8 @@
{% extends 'partials/generic-detail.html' %} {% extends 'partials/generic-detail.html' %}
{% load cache %}
{% block tbody %} {% block tbody %}
{% cache 600 object_position_detail request.user.id object %}
{% for key, item in object.items %} {% for key, item in object.items %}
<tr> <tr>
{% if key == 'trade_ids' %} {% if key == 'trade_ids' %}
@ -30,4 +32,5 @@
{% endif %} {% endif %}
</tr> </tr>
{% endfor %} {% endfor %}
{% endcache %}
{% endblock %} {% endblock %}

View File

@ -1,5 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
<table {% cache 600 objects_positions request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -99,4 +101,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,8 +1,9 @@
{% load static %} {% load static %}
{% load cache %}
{% for plan in plans %} {% cache 600 objects_plans request.user.id plans %}
{% for plan in plans %}
<div class="box"> <div class="box">
<article class="media"> <article class="media">
<div class="media-left"> <div class="media-left">
@ -43,6 +44,6 @@
</div> </div>
</article> </article>
</div> </div>
{% endfor %} {% endfor %}
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_profit request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -29,4 +30,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_risk request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -62,4 +63,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_signals request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -96,4 +97,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_strategies request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -95,4 +96,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_trades request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -89,4 +90,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_tradingtimes request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -58,4 +59,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,6 +1,7 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_trenddirections request.user.id object_list %}
<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"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
@ -52,4 +53,5 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
{% endcache %}