From db83d57f9b53c6a5ab2a31f41581e37877bcf831 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bompard?= Date: Mon, 3 Jun 2024 11:54:39 +0200 Subject: [PATCH] Fix the DN end datetime to be naive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Bompard --- fedbadges/cached.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fedbadges/cached.py b/fedbadges/cached.py index 360bb5c..2bbd5c7 100644 --- a/fedbadges/cached.py +++ b/fedbadges/cached.py @@ -160,7 +160,6 @@ def _year_split_query(self, **grep_kwargs): def _first_message_timestamp(self, **grep_kwargs): key = self._get_key(**grep_kwargs) key = f"{key}|first_timestamp" - now = datetime.datetime.now(tz=datetime.timezone.utc) get_first_kwargs = grep_kwargs.copy() # remove grep() args that are not allowed by get_first() for kwarg in ("defer", "rows_per_page", "page"): @@ -193,7 +192,9 @@ def _get_first_timestamp(**kwargs): if kwargs["start"] is None or start > kwargs["start"]: kwargs["start"] = start if kwargs["start"] is not None and "end" not in kwargs: - kwargs["end"] = now + # user creation time is naive, let's keep the end dt naive as well + # also, the datanommer column is currently naive, so, let's be consistent + kwargs["end"] = datetime.datetime.now() log.debug("Getting first DN message for: %r", kwargs) first_message = Message.get_first(**kwargs)