diff --git a/daemons/notify.py b/daemons/notify.py index e4a80d0..639f3df 100644 --- a/daemons/notify.py +++ b/daemons/notify.py @@ -11,10 +11,12 @@ from helpers.ruz import ruz def process(): + time_now = now() + print(time_now) for user in mongo.users_collection.find({"notify_minutes": {"$ne": None}, "hse_id": {"$ne": None}}): for lesson in mongo.lessons_collection.find({ "hse_user_id": user["hse_id"], - "begin": {"$lte": now() + datetime.timedelta(minutes=user["notify_minutes"])}, + "begin": {"$lte": time_now + datetime.timedelta(minutes=user["notify_minutes"])}, "notified": False }): ans = "" @@ -30,7 +32,6 @@ def process(): except ApiTelegramException: pass mongo.lessons_collection.update_one({"_id": lesson['_id']}, {"$set": {"notified": True}}) - time_now = now() for user in mongo.users_collection.find({"next_daily_notify_time": {"$lte": time_now}}): user_model = UserSchema().load(user) if time_now.weekday() != 6: diff --git a/helpers/__init__.py b/helpers/__init__.py index 197a1c3..15d6879 100644 --- a/helpers/__init__.py +++ b/helpers/__init__.py @@ -20,6 +20,9 @@ def get_next_daily_notify_time(user: User, time_now: datetime.datetime | None = hour=hours, minute=minutes ) + print('now time is', time_now) + print('user wants to notify at', hours, minutes) if time_now.hour * 60 + time_now.minute < hours * 60 + minutes: + print('go to next day') next_time = next_time + datetime.timedelta(days=1) return next_time