This commit is contained in:
Administrator 2022-10-22 22:33:48 +03:00
parent c9ad723222
commit 6a69681e9f
2 changed files with 6 additions and 2 deletions

View File

@ -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:

View File

@ -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