Suppression de requêtes en trop

This commit is contained in:
Jean-Marie Favreau 2025-01-31 12:17:03 +01:00
parent 129e26555b
commit c789a7c4c7

View File

@ -28,6 +28,7 @@ def daterange(start, end, step=timedelta(1)):
class DayInCalendar:
midnight = time(0, 0, 0)
cats = None
def __init__(self, d, on_requested_interval=True):
self.date = d
@ -138,9 +139,10 @@ class DayInCalendar:
def events_by_category_ordered(self):
from .models import Category
cats = Category.objects.order_by('position')
if DayInCalendar.cats is None:
DayInCalendar.cats = Category.objects.order_by('position')
result = []
for c in cats:
for c in DayInCalendar.cats:
if c.name in self.events_by_category:
result.append((c.name, self.events_by_category[c.name]))
return result