Améliorations performances

See #294
This commit is contained in:
Jean-Marie Favreau 2025-01-31 15:34:21 +01:00
parent d7dec94beb
commit 0e9669bcd3
2 changed files with 12 additions and 5 deletions

View File

@ -214,6 +214,8 @@ class CalendarList:
self.calendar_days = None self.calendar_days = None
def is_today(self):
return self.firstdate == date.today()
def build_internal(self): def build_internal(self):
# create a list of DayInCalendars # create a list of DayInCalendars
@ -303,6 +305,9 @@ class CalendarList:
def calendar_days_list(self): def calendar_days_list(self):
return list(self.get_calendar_days().values()) return list(self.get_calendar_days().values())
def nb_days(self):
return (self.c_lastdate - self.c_firstdate).days + 1
def time_intervals_list(self, onlyfirst=False): def time_intervals_list(self, onlyfirst=False):
ds = self.calendar_days_list() ds = self.calendar_days_list()
result = [] result = []

View File

@ -14,7 +14,7 @@
{% endblock %} {% endblock %}
{% block navigation-menu %} {% block navigation-menu %}
{% cache 90000 navigation_links_upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.calendar_days_list|length %} {% cache 90000 navigation_links_upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.nb_days %}
{% navigation_links filter category %} {% navigation_links filter category %}
{% endcache %} {% endcache %}
{% endblock %} {% endblock %}
@ -26,23 +26,25 @@
<article id="filters"> <article id="filters">
{% cache 60000 upcoming_title user.is_authenticated calendar.firstdate filter.get_url category calendar.nb_days %}
<header><h1 id="index-avenir">{% block title %}{% block og_title %} <header><h1 id="index-avenir">{% block title %}{% block og_title %}
{% if category %}{{ category.name }}{% else %}Événements{% endif %} {% if category %}{{ category.name }}{% else %}Événements{% endif %}
{% if calendar.calendar_days_list.0.is_today %} {% if calendar.is_today %}
à venir à venir
{% else %} {% else %}
du {{ calendar.calendar_days_list.0.date| date:"l j F Y" }} du {{ calendar.firstdate | date:"l j F Y" }}
{% if calendar.calendar_days_list|length > 1 %} {% if calendar.nb_days > 1 %}
et suivants et suivants
{% endif %} {% endif %}
{% endif %}{% if filter.has_location %} à {{ filter.get_position }}{% endif %} {% endif %}{% if filter.has_location %} à {{ filter.get_position }}{% endif %}
{% endblock %}{% endblock %}</h1></header> {% endblock %}{% endblock %}</h1></header>
{% endcache %}
{% include "agenda_culturel/filter-inc.html" with filter=filter noarticle=1 %} {% include "agenda_culturel/filter-inc.html" with filter=filter noarticle=1 %}
{% with cache_timeout=user.is_authenticated|yesno:"30,600" %} {% with cache_timeout=user.is_authenticated|yesno:"30,600" %}
{% cache cache_timeout upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.calendar_days_list|length %} {% cache cache_timeout upcoming user.is_authenticated calendar.firstdate filter.get_url category calendar.nb_days %}
<footer> <footer>
{% if category %} {% if category %}