initial commit (backend)
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
"""
|
||||
Полный сброс прогресса пользователя.
|
||||
Очищает ВСЕ данные по играм, урокам, чат-учителю, достижениям.
|
||||
Не трогает: users (остаётся), tts_cache (аудио).
|
||||
|
||||
Запуск: python3 full_reset.py
|
||||
"""
|
||||
import asyncio
|
||||
import asyncpg
|
||||
from config import DB_CONFIG
|
||||
|
||||
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
|
||||
|
||||
# Список таблиц для очистки (по user_id)
|
||||
user_tables = [
|
||||
"user_progress", # Филворды
|
||||
"sentence_progress", # Предложения
|
||||
"typing_progress", # Печать
|
||||
"word_quiz_progress", # Выбери слово
|
||||
"bubble_words_progress", # Пузыри слов
|
||||
"user_learning_answers", # Ответы на уроки
|
||||
"user_lesson_progress", # Прогресс уроков
|
||||
"user_topic_progress", # Прогресс тем
|
||||
"user_skill_mastery", # Мастерство
|
||||
"learning_sessions", # Сессии обучения
|
||||
"teacher_chat_history", # История чата учителя
|
||||
"teacher_ai_usage", # AI-команды
|
||||
"chat_history", # AI-чат
|
||||
"chat_usage", # Использование AI
|
||||
"user_achievements", # Достижения
|
||||
"daily_logins", # Входы
|
||||
"ai_user_context", # AI-контекст
|
||||
]
|
||||
|
||||
total_deleted = 0
|
||||
|
||||
for table in user_tables:
|
||||
try:
|
||||
result = await conn.execute(f"""
|
||||
DELETE FROM {table} WHERE user_id = $1
|
||||
""", USER_ID)
|
||||
affected = int(result.split()[-1])
|
||||
total_deleted += affected
|
||||
print(f"🗑️ {table}: удалено {affected}")
|
||||
except Exception as e:
|
||||
print(f"⚠️ {table}: {str(e)}")
|
||||
|
||||
# Сбрасываем last_completed_level
|
||||
await conn.execute("""
|
||||
UPDATE users SET last_completed_level = 0, current_level = 'A1'
|
||||
WHERE telegram_id = $1
|
||||
""", USER_ID)
|
||||
print("✅ last_completed_level = 0, current_level = A1")
|
||||
|
||||
# Очищаем архив ответов
|
||||
try:
|
||||
result = await conn.execute("""
|
||||
DELETE FROM user_learning_answers_archive WHERE user_id = $1
|
||||
""", USER_ID)
|
||||
print(f"🗑️ user_learning_answers_archive: удалено {result.split()[-1]}")
|
||||
except Exception as e:
|
||||
print(f"⚠️ archive: {str(e)}")
|
||||
|
||||
await pool.close()
|
||||
print(f"\n🎉 Готово! Удалено {total_deleted} записей.")
|
||||
print("Можно начинать тестирование с чистого листа!")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user