From f847ee84a95476237b782b445269b340ecde1a61 Mon Sep 17 00:00:00 2001 From: Stan Girard Date: Sat, 16 Sep 2023 16:09:38 +0200 Subject: [PATCH] fix(notifications): dead notifications that are still present long after (#1186) --- backend/models/databases/supabase/notifications.py | 4 ++++ ...-272be8a1-ef4f-41a4-95f8-766b12e08cea_Petit-Déj GenAI.pptx | 0 2 files changed, 4 insertions(+) create mode 100644 backend/tmp-file-272be8a1-ef4f-41a4-95f8-766b12e08cea_Petit-Déj GenAI.pptx diff --git a/backend/models/databases/supabase/notifications.py b/backend/models/databases/supabase/notifications.py index 2d6e96d29..6fed9e5b4 100644 --- a/backend/models/databases/supabase/notifications.py +++ b/backend/models/databases/supabase/notifications.py @@ -1,3 +1,4 @@ +from datetime import datetime, timedelta from typing import Optional from uuid import UUID @@ -115,10 +116,13 @@ class Notifications(Repository): Returns: list[Notification]: The notifications """ + five_minutes_ago = datetime.now() - timedelta(minutes=5) + notifications = ( self.db.from_("notifications") .select("*") .filter("chat_id", "eq", chat_id) + .filter("datetime", "lt", five_minutes_ago) .execute() ).data diff --git a/backend/tmp-file-272be8a1-ef4f-41a4-95f8-766b12e08cea_Petit-Déj GenAI.pptx b/backend/tmp-file-272be8a1-ef4f-41a4-95f8-766b12e08cea_Petit-Déj GenAI.pptx new file mode 100644 index 000000000..e69de29bb