first lesson

This commit is contained in:
Administrator 2023-04-10 22:01:34 +03:00
parent 5f599aa578
commit f2f4d4ca05

View File

@ -2,6 +2,8 @@ import logging
from typing import Optional
from daemons.bot import bot
from helpers import now
from helpers.models import UserSchema
from helpers.mongo import mongo
@ -37,7 +39,10 @@ class Processor:
self.message = data['request']['original_utterance'].lower()
def get_lesson_for_user(self, hse_id: int):
for lesson in mongo.lessons_collection.find({"hse_user_id": hse_id}).sort([("begin", 1)]):
user = mongo.users_collection.find_one({"hse_id": hse_id})
user = UserSchema().load(user)
t = now(user)
for lesson in mongo.lessons_collection.find({"hse_user_id": hse_id, "begin": {"$gte": t}}).sort([("begin", 1)]):
return lesson
return None