Skip to content
This repository has been archived by the owner on Dec 15, 2024. It is now read-only.

Commit

Permalink
fix: asdsad
Browse files Browse the repository at this point in the history
  • Loading branch information
TatarinAlba committed Nov 23, 2024
1 parent 616122f commit cb9d373
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions backend/src/api/lifespan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import asyncio
import json
from contextlib import asynccontextmanager
from datetime import UTC, datetime

from beanie import init_beanie
from fastapi import FastAPI
Expand Down Expand Up @@ -53,16 +52,16 @@ async def push_notification():
for notification in notifications:
sent_notification_number = len(notification.event_dates)
for start_date in notification.event_dates:
days_before = None
if (start_date - datetime.now(UTC)).days == 30:
days_before = 30
elif (start_date - datetime.now(UTC)).days == 7:
days_before = 7
elif (start_date - datetime.now(UTC)).days == 1:
days_before = 1
sent_notification_number -= 1
elif (start_date - datetime.now(UTC)).days < 0:
sent_notification_number -= 1
days_before = 4
# if (start_date - datetime.now(UTC)).days == 30:
# days_before = 30
# elif (start_date - datetime.now(UTC)).days == 7:
# days_before = 7
# elif (start_date - datetime.now(UTC)).days == 1:
# days_before = 1
# sent_notification_number -= 1
# elif (start_date - datetime.now(UTC)).days < 0:
# sent_notification_number -= 1
if days_before is not None:
outMsg: str
if notification.sport_id is not None:
Expand All @@ -72,7 +71,7 @@ async def push_notification():
try:
webpush(
subscription_info=notification.subscription_info,
data=json.dumps({"title": "Напоминание", "body": outMsg}),
data=json.dumps({"message": outMsg}),
vapid_private_key=VAPID_PRIVATE_KEY,
vapid_claims={"sub": "mailto:[email protected]"},
)
Expand Down

0 comments on commit cb9d373

Please sign in to comment.