[Eva] **Цель:** превратить `support_screen.dar #55
@@ -7,39 +7,6 @@ from database import get_pool
|
||||
router = APIRouter(prefix="/sentences", tags=["sentences"])
|
||||
|
||||
|
||||
@router.get("/{sentence_id}/hint")
|
||||
async def get_sentence_hint(sentence_id: int, request: Request):
|
||||
"""Получить правильное предложение в качестве подсказки (одноразово)"""
|
||||
telegram_id, _ = await require_auth(request)
|
||||
|
||||
pool = await get_pool()
|
||||
async with pool.acquire() as conn:
|
||||
row = await conn.fetchrow(
|
||||
"SELECT sentence_pl FROM sentences WHERE id = $1", sentence_id
|
||||
)
|
||||
if not row:
|
||||
raise HTTPException(404, "Sentence not found")
|
||||
|
||||
# 🔧 ФИКС (24.09.2026): sentence_hint_no_limit — лимит 1 раз на предложение.
|
||||
already_used = await conn.fetchval(
|
||||
"SELECT 1 FROM sentence_hints_used WHERE user_id = $1 AND sentence_id = $2",
|
||||
telegram_id, sentence_id
|
||||
)
|
||||
if already_used:
|
||||
raise HTTPException(403, "Hint already used for this sentence")
|
||||
|
||||
# Записываем использование
|
||||
await conn.execute("""
|
||||
INSERT INTO sentence_hints_used (user_id, sentence_id)
|
||||
VALUES ($1, $2)
|
||||
ON CONFLICT (user_id, sentence_id) DO NOTHING
|
||||
""", telegram_id, sentence_id)
|
||||
|
||||
return {
|
||||
"sentence_pl": row["sentence_pl"],
|
||||
}
|
||||
|
||||
|
||||
def load_sentences_from_csv(filename):
|
||||
"""Загружает предложения из CSV файла (формат: polish,english,russian,ukrainian)."""
|
||||
sentences = []
|
||||
|
||||
Reference in New Issue
Block a user