Skip to content

Commit

Permalink
Fix @available-slots view performance
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Jan 10, 2024
1 parent e9f5d22 commit 1e05a1c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog
2.4.0 (unreleased)
------------------

- Perfomance refactoring for @available-slots view
[folix-01]

- Split booking notification gateways to 'App IO', 'Email' and 'SMS'
[folix-01]

Expand Down
7 changes: 4 additions & 3 deletions src/redturtle/prenotazioni/adapters/booking_code.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from redturtle.prenotazioni.content.prenotazione import IPrenotazione
from zope.component import adapter
import hashlib

from zope.component import Interface
from zope.component import adapter
from zope.interface import implementer

import hashlib
from redturtle.prenotazioni.content.prenotazione import IPrenotazione


class IBookingCodeGenerator(Interface):
Expand Down
9 changes: 8 additions & 1 deletion src/redturtle/prenotazioni/utilities/dateutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
from datetime import timedelta

import six
from cachetools import TTLCache
from cachetools import cached
from plone.app.event.base import default_timezone

from redturtle.prenotazioni import tznow


@cached(cache=TTLCache(maxsize=10, ttl=timedelta(hours=1), timer=datetime.now))
def get_default_timezone(as_tzinfo):
return default_timezone(as_tzinfo=as_tzinfo)


def hm2handm(hm):
"""This is a utility function that will return the hour and date of day
to the value passed in the string hm
Expand All @@ -33,7 +40,7 @@ def hm2DT(day, hm, tzinfo=None):
:param tzinfo: a timezone object (default: the default local timezone as in plone)
"""
if tzinfo is None:
tzinfo = default_timezone(as_tzinfo=True)
tzinfo = get_default_timezone(as_tzinfo=True)

if not hm or hm == "--NOVALUE--" or hm == ("--NOVALUE--",):
return None
Expand Down

0 comments on commit 1e05a1c

Please sign in to comment.