From c4353bc63c41c6a92ecde0e986e6639ff4fd0576 Mon Sep 17 00:00:00 2001 From: Drobysh Date: Tue, 22 Sep 2026 12:26:51 +0000 Subject: [PATCH] =?UTF-8?q?chore(scripts):=20=D1=81=D0=BA=D1=80=D0=B8?= =?UTF-8?q?=D0=BF=D1=82=20=D1=81=D0=B1=D1=80=D0=BE=D1=81=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B3=D1=80=D0=B5=D1=81=D1=81=D0=B0=20=D1=83=D1=87?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8F=20(22.09.2026)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reset_teacher_progress.py | 78 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 reset_teacher_progress.py diff --git a/reset_teacher_progress.py b/reset_teacher_progress.py new file mode 100644 index 0000000..99da99d --- /dev/null +++ b/reset_teacher_progress.py @@ -0,0 +1,78 @@ +""" +Сброс прогресса учителя для ВСЕХ пользователей. + +Очищает таблицы: +- user_learning_answers (все ответы) +- user_lesson_progress (прогресс уроков) +- user_topic_progress (прогресс тем) +- user_skill_mastery (мастерство) +- learning_sessions (сессии) +- teacher_chat_history (история чата учителя) +- teacher_ai_usage (AI-лимиты) +- ai_user_context (AI-контекст) + +НЕ трогает: users, user_progress (филворды), sentence_progress, typing_progress, +word_quiz_progress, bubble_words_progress, user_achievements, daily_logins. + +Запуск: + python3 reset_teacher_progress.py # спросит подтверждение + python3 reset_teacher_progress.py --force # без подтверждения +""" +import asyncio +import sys + +import asyncpg + +from config import DB_CONFIG + + +TABLES = [ + "user_learning_answers", + "user_lesson_progress", + "user_topic_progress", + "user_skill_mastery", + "learning_sessions", + "teacher_chat_history", + "teacher_ai_usage", + "ai_user_context", +] + + +async def main(): + pool = await asyncpg.create_pool(**DB_CONFIG) + async with pool.acquire() as conn: + total = 0 + for table in TABLES: + try: + result = await conn.execute(f"DELETE FROM {table}") + affected = int(result.split()[-1]) + total += affected + print(f"🗑️ {table}: удалено {affected}") + except Exception as e: + print(f"⚠️ {table}: {e}") + + # Сбрасываем last_completed_level у всех (только для учителя) + # НЕ трогаем current_level — оставляем A1 у всех + result = await conn.execute( + "UPDATE users SET current_level = 'A1' WHERE current_level != 'A1'" + ) + print(f"✅ users.current_level → A1") + + await pool.close() + print(f"\n🎉 Готово! Удалено {total} записей.") + + +if __name__ == "__main__": + if len(sys.argv) < 2 or sys.argv[1] != "--force": + print("⚠️ ЭТОТ СКРИПТ УДАЛИТ ВЕСЬ ПРОГРЕСС УЧИТЕЛЯ У ВСЕХ ПОЛЬЗОВАТЕЛЕЙ!") + print(" Будут очищены: ответы, прогресс уроков, темы, мастерство, сессии,") + print(" история чата учителя, AI-лимиты.") + print("") + print(" НЕ трогает: users, филворды, предложения, печать, квиз, пузыри, достижения.") + print("") + confirm = input("Напиши YES для подтверждения: ") + if confirm != "YES": + print("❌ Отменено.") + sys.exit(0) + + asyncio.run(main())