Enable caching via DB and update cache timeouts
This commit is contained in:
parent
9ce5d525b3
commit
27c7238a82
11 changed files with 281 additions and 283 deletions
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 5.1.2 on 2025-03-15 22:05
|
||||
# Generated by Django 5.1.2 on 2025-03-16 04:58
|
||||
|
||||
import django.contrib.auth.models
|
||||
import django.contrib.auth.validators
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 5.1.2 on 2025-03-15 22:05
|
||||
# Generated by Django 5.1.2 on 2025-03-16 04:58
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ from cards.models import Card
|
|||
register = template.Library()
|
||||
|
||||
@register.inclusion_tag('templatetags/card_multiselect.html')
|
||||
def card_multiselect(field_name, label, placeholder, cards=None, selected_values=None, cache_timeout=86400, cache_key="cards_multiselect"):
|
||||
def card_multiselect(field_name, label, placeholder, cards=None, selected_values=None, cache_timeout=86400):
|
||||
"""
|
||||
Renders a multiselect field for choosing cards while supporting quantity data.
|
||||
|
||||
|
|
@ -50,6 +50,5 @@ def card_multiselect(field_name, label, placeholder, cards=None, selected_values
|
|||
'cards': cards,
|
||||
'placeholder': placeholder,
|
||||
'selected_values': list(selected_cards.keys()),
|
||||
'cache_timeout': cache_timeout,
|
||||
'cache_key': cache_key,
|
||||
'cache_timeout': cache_timeout
|
||||
}
|
||||
|
|
@ -286,7 +286,7 @@ if DEBUG:
|
|||
else:
|
||||
CACHES = {
|
||||
"default": {
|
||||
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
|
||||
"LOCATION": "unique-snowflake",
|
||||
"BACKEND": "django.core.cache.backends.db.DatabaseCache",
|
||||
"LOCATION": "site_cache",
|
||||
}
|
||||
}
|
||||
|
|
@ -10,7 +10,6 @@ from django.views.decorators.cache import cache_page
|
|||
from django.template.response import TemplateResponse
|
||||
from django.http import HttpResponseRedirect
|
||||
|
||||
@method_decorator(cache_page(60), name='get')
|
||||
class HomePageView(TemplateView):
|
||||
template_name = "home/home.html"
|
||||
|
||||
|
|
|
|||
|
|
@ -22,5 +22,8 @@ uv run python manage.py migrate
|
|||
echo "Loading seed data..."
|
||||
uv run python manage.py loaddata seed/0*
|
||||
|
||||
echo "Creating cache table..."
|
||||
uv run python manage.py createcachetable
|
||||
|
||||
echo "Seeding default friend codes..."
|
||||
uv run python manage.py seed_default_friend_codes
|
||||
|
|
@ -85,9 +85,9 @@
|
|||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<!-- Featured Offers -->
|
||||
<div>
|
||||
{% cache 86400 featured_offers %}
|
||||
<div class="p-4">
|
||||
<h5 class="text-xl text-center font-semibold whitespace-nowrap truncate mb-0">Featured Offers</h5>
|
||||
{% cache 60 featured_offers %}
|
||||
<div class="p-4 text-center ">
|
||||
<h5 class="text-xl font-semibold whitespace-nowrap truncate mb-0">Featured Offers</h5>
|
||||
</div>
|
||||
<div class="p-4">
|
||||
<!-- Tab contents -->
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
<!-- Recent Offers -->
|
||||
<div>
|
||||
{% cache 60 recent_offers %}
|
||||
<div class="text-center text-base-content p-4">
|
||||
<div class="text-center p-4">
|
||||
<h5 class="text-xl font-semibold whitespace-nowrap truncate mb-0">Recent Offers</h5>
|
||||
</div>
|
||||
<div class="p-4">
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<span class="label-text">{{ label }}</span>
|
||||
</label>
|
||||
<select name="{{ field_name }}" id="{{ field_id }}" class="select select-bordered w-full card-multiselect" data-placeholder="{{ placeholder }}" multiple>
|
||||
{% cache cache_timeout cache_key selected_values|join:"," %}
|
||||
{% cache cache_timeout card_multiselect selected_values|join:"," %}
|
||||
<option value="" disabled>{{ placeholder }}</option>
|
||||
{% for card in cards %}
|
||||
<option
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{% load gravatar card_badge %}
|
||||
{% load gravatar card_badge cache %}
|
||||
|
||||
<div class="card card-border bg-base-100 shadow-lg w-96 md:w-80 lg:w-96">
|
||||
{% cache 60 trade_acceptance acceptance.pk %}
|
||||
<div class="card card-border bg-base-100 shadow-lg w-96 md:w-80 lg:w-96">
|
||||
<!-- Header -->
|
||||
<div class="py-4 mx-2 sm:mx-4">
|
||||
<div class="flex justify-between items-center">
|
||||
|
|
@ -48,4 +49,5 @@
|
|||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endcache %}
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
{% load gravatar card_badge %}
|
||||
{% load gravatar card_badge cache %}
|
||||
|
||||
<!--
|
||||
Define the Alpine component only once.
|
||||
-->
|
||||
<script>
|
||||
if (!window.tradeOfferCard) {
|
||||
{% cache 60 trade_offer offer.pk %}
|
||||
<script>
|
||||
if (!window.tradeOfferCard) {
|
||||
window.tradeOfferCard = function() {
|
||||
return {
|
||||
flipped: false,
|
||||
|
|
@ -16,14 +14,10 @@ if (!window.tradeOfferCard) {
|
|||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
</script>
|
||||
|
||||
<!--
|
||||
The outer div now only establishes Alpine's data context.
|
||||
The dynamic height adjustment (x-init & x-effect with x-ref) has been removed.
|
||||
-->
|
||||
<div x-data="tradeOfferCard()" class="transition-all duration-500 trade-offer-card"
|
||||
<div x-data="tradeOfferCard()" class="transition-all duration-500 trade-offer-card"
|
||||
@toggle-all.window="setBadge($event.detail.expanded)">
|
||||
|
||||
<!-- Flip container providing perspective -->
|
||||
|
|
@ -251,9 +245,9 @@ if (!window.tradeOfferCard) {
|
|||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
<style>
|
||||
/* Ensure proper 3D transformations on the rotating element */
|
||||
.flip-inner {
|
||||
transform-style: preserve-3d;
|
||||
|
|
@ -271,4 +265,5 @@ if (!window.tradeOfferCard) {
|
|||
.rotate-y-180 {
|
||||
transform: rotateY(180deg);
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
{% endcache %}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 5.1.2 on 2025-03-15 22:05
|
||||
# Generated by Django 5.1.2 on 2025-03-16 04:58
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue