From 1df1119d1198f38666409c6e7885e34f718560ad Mon Sep 17 00:00:00 2001 From: Drobysh Date: Fri, 16 Oct 2026 11:58:50 +0000 Subject: [PATCH] =?UTF-8?q?[Eva]=20B5.1:=20/next=20=E2=80=94=20=D1=83?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D1=82=D1=8C=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82?= =?UTF-8?q?=D1=80=20=D0=BF=D0=BE=20=D1=83=D1=80=D0=BE=D0=B2=D0=BD=D1=8E=20?= =?UTF-8?q?(=D0=B5=D0=B4=D0=B8=D0=BD=D1=8B=D0=B9=20=D0=BF=D1=83=D0=BB)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routers/sentences.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) 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!"}