🌊 Волна 10: backend client-controlled + лимиты (5 багов)

- client_controlled_hints_game: hints_used из user_progress (game.py + database.py)
- client_controlled_hints_bubblewords: current_hints_used из bubble_words_progress (bubblewords.py + database.py)
- client_controlled_mistakes_wordquiz: current_mistakes из word_quiz_progress (wordquiz.py + database.py)
- sentence_hint_no_limit: таблица sentence_hints_used + лимит 1 раз (sentences.py + database.py)
- typing_hint_no_limit: таблица typing_hints_used + лимит 1 раз (typing.py + database.py)

Аудит v2: Issue #5, backend 5/10 задач
This commit is contained in:
2026-09-24 08:58:02 +00:00
parent 037b340cee
commit e9ebaf3351
6 changed files with 129 additions and 16 deletions
+46
View File
@@ -658,6 +658,19 @@ async def init_db():
""")
logger.info("Added level column to word_quiz_progress")
# 🔧 ФИКС (24.09.2026): client_controlled_mistakes_wordquiz —
# серверный счётчик mistakes для текущего слова.
col_exists = await conn.fetchval("""
SELECT 1 FROM information_schema.columns
WHERE table_name = 'word_quiz_progress' AND column_name = 'current_mistakes'
""")
if not col_exists:
await conn.execute("""
ALTER TABLE word_quiz_progress
ADD COLUMN current_mistakes INT DEFAULT 0
""")
logger.info("Added current_mistakes column to word_quiz_progress")
# ============ bubble_words_progress ============
await conn.execute("""
CREATE TABLE IF NOT EXISTS bubble_words_progress (
@@ -680,6 +693,19 @@ async def init_db():
""")
logger.info("Added level column to bubble_words_progress")
# 🔧 ФИКС (24.09.2026): client_controlled_hints_bubblewords —
# серверный hints_used для текущего уровня пузырей.
col_exists = await conn.fetchval("""
SELECT 1 FROM information_schema.columns
WHERE table_name = 'bubble_words_progress' AND column_name = 'current_hints_used'
""")
if not col_exists:
await conn.execute("""
ALTER TABLE bubble_words_progress
ADD COLUMN current_hints_used INT DEFAULT 0
""")
logger.info("Added current_hints_used column to bubble_words_progress")
# ============ wrong_because_explanations ============
await conn.execute("""
CREATE TABLE IF NOT EXISTS wrong_because_explanations (
@@ -857,6 +883,26 @@ async def init_db():
await conn.execute("CREATE INDEX IF NOT EXISTS idx_archive_user_date ON user_learning_answers_archive(user_id, created_at)")
await conn.execute("CREATE INDEX IF NOT EXISTS idx_archive_skill_tag ON user_learning_answers_archive(skill_tag)")
# 🔧 ФИКС (24.09.2026): sentence_hint_no_limit + typing_hint_no_limit —
# таблицы для лимита подсказок (1 раз на предложение).
await conn.execute("""
CREATE TABLE IF NOT EXISTS sentence_hints_used (
user_id BIGINT REFERENCES users(telegram_id) ON DELETE CASCADE,
sentence_id INTEGER REFERENCES sentences(id) ON DELETE CASCADE,
used_at TIMESTAMP DEFAULT NOW(),
PRIMARY KEY (user_id, sentence_id)
)
""")
await conn.execute("""
CREATE TABLE IF NOT EXISTS typing_hints_used (
user_id BIGINT REFERENCES users(telegram_id) ON DELETE CASCADE,
sentence_id INTEGER REFERENCES sentences(id) ON DELETE CASCADE,
used_at TIMESTAMP DEFAULT NOW(),
PRIMARY KEY (user_id, sentence_id)
)
""")
# ============ Индексы ============
await conn.execute("CREATE INDEX IF NOT EXISTS idx_levels_number ON levels(level_number)")
await conn.execute("CREATE INDEX IF NOT EXISTS idx_levels_level ON levels(level)")