[Eva] B5.1: /next — убрать фильтр по уровню (единый пул)
This commit is contained in:
@@ -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!"}
|
||||
|
||||
Reference in New Issue
Block a user