65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
"""
|
|
Сброс прогресса пользователя по разделу "Учитель" и "Уроки".
|
|
Очищает: user_learning_answers, user_lesson_progress, user_topic_progress,
|
|
user_skill_mastery, learning_sessions, teacher_chat_history, teacher_ai_usage.
|
|
|
|
Запуск: python3 reset_my_progress.py
|
|
"""
|
|
import asyncio
|
|
import asyncpg
|
|
from config import DB_CONFIG
|
|
|
|
# ID пользователя для сброса (твой Telegram ID)
|
|
USER_ID = 6694989403
|
|
|
|
|
|
async def main():
|
|
pool = await asyncpg.create_pool(**DB_CONFIG)
|
|
|
|
async with pool.acquire() as conn:
|
|
# Проверяем, что пользователь существует
|
|
user_exists = await conn.fetchval("""
|
|
SELECT 1 FROM users WHERE telegram_id = $1
|
|
""", USER_ID)
|
|
|
|
if not user_exists:
|
|
print(f"❌ Пользователь {USER_ID} не найден!")
|
|
await pool.close()
|
|
return
|
|
|
|
# Список таблиц для очистки
|
|
tables = [
|
|
"user_learning_answers",
|
|
"user_lesson_progress",
|
|
"user_topic_progress",
|
|
"user_skill_mastery",
|
|
"learning_sessions",
|
|
"teacher_chat_history",
|
|
"teacher_ai_usage",
|
|
]
|
|
|
|
for table in tables:
|
|
result = await conn.execute(f"""
|
|
DELETE FROM {table} WHERE user_id = $1
|
|
""", USER_ID)
|
|
affected = int(result.split()[-1])
|
|
print(f"🗑️ {table}: удалено {affected} записей")
|
|
|
|
# Также очищаем ai_user_context
|
|
result = await conn.execute("""
|
|
DELETE FROM ai_user_context WHERE user_id = $1
|
|
""", USER_ID)
|
|
print(f"🗑️ ai_user_context: удалено {result.split()[-1]} записей")
|
|
|
|
# Сбрасываем last_completed_level
|
|
await conn.execute("""
|
|
UPDATE users SET last_completed_level = 0 WHERE telegram_id = $1
|
|
""", USER_ID)
|
|
print("✅ last_completed_level сброшен на 0")
|
|
|
|
await pool.close()
|
|
print("\n🎉 Готово! Можно начинать заново!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main()) |