diff --git a/routers/sentences.py b/routers/sentences.py index c732c98..9511304 100644 --- a/routers/sentences.py +++ b/routers/sentences.py @@ -100,25 +100,23 @@ async def get_next_sentence(request: Request): pool = await get_pool() async with pool.acquire() as conn: user = await conn.fetchrow( - "SELECT app_language, current_level, difficulty FROM users WHERE telegram_id = $1", telegram_id + "SELECT app_language, difficulty FROM users WHERE telegram_id = $1", telegram_id ) if not user: raise HTTPException(401, "User not registered") lang = user["app_language"] or "pl" - current_level = user["current_level"] or "A1" difficulty = user["difficulty"] or "medium" - # Находим случайное непройденное предложение нужного уровня + # Находим случайное непройденное предложение (единый пул) row = await conn.fetchrow(""" SELECT s.* FROM sentences s - WHERE s.level = $1 - AND s.id NOT IN ( - SELECT sentence_id FROM sentence_progress WHERE user_id = $2 AND completed_at IS NOT NULL + WHERE s.id NOT IN ( + SELECT sentence_id FROM sentence_progress WHERE user_id = $1 AND completed_at IS NOT NULL ) ORDER BY RANDOM() LIMIT 1 - """, current_level, telegram_id) + """, telegram_id) if not row: return {"completed": True, "message": "All sentences completed!"}