initial commit (backend)
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
"""
|
||||
Патч: исправляет колонку text_pl в question_options там, где при заполнении
|
||||
контента по ошибке продублировали русский перевод вместо настоящей польской
|
||||
фразы (вопросы типа "Co oznacza / Co znaczy ...?").
|
||||
|
||||
Затронуто 12 question_id по темам: greetings, family, food, home,
|
||||
numbers_time (3 шт.), colors_clothes, weather_seasons.
|
||||
|
||||
Запуск на сервере:
|
||||
python3 fix_polish_options.py
|
||||
Требует переменную DB_CONFIG из config.py (как остальные твои скрипты).
|
||||
|
||||
Скрипт идемпотентен: можно запускать повторно, ничего не сломает —
|
||||
он просто перезапишет text_pl тем же корректным значением.
|
||||
"""
|
||||
import asyncio
|
||||
import asyncpg
|
||||
from config import DB_CONFIG
|
||||
|
||||
|
||||
# Каждая запись: (question_id, option_key, правильный польский текст)
|
||||
FIXES = [
|
||||
# ==================== Тема 1: Greetings ====================
|
||||
("a1_greetings_t09", "A", "Jak się nazywasz?"),
|
||||
("a1_greetings_t09", "B", "Jak się masz?"),
|
||||
("a1_greetings_t09", "C", "Gdzie mieszkasz?"),
|
||||
("a1_greetings_t09", "D", "Do widzenia."),
|
||||
|
||||
# ==================== Тема 3: Family ====================
|
||||
# Один и тот же набор опций встречается в уроке и в тесте
|
||||
("a1_family_l07_q1", "A", "Masz siostrę?"),
|
||||
("a1_family_l07_q1", "B", "Czy to jest twoja siostra?"),
|
||||
("a1_family_l07_q1", "C", "Jesteś siostrą?"),
|
||||
("a1_family_l07_q1", "D", "Gdzie jest twoja siostra?"),
|
||||
|
||||
("a1_family_t06", "A", "Masz siostrę?"),
|
||||
("a1_family_t06", "B", "Czy to jest twoja siostra?"),
|
||||
("a1_family_t06", "C", "Jesteś siostrą?"),
|
||||
("a1_family_t06", "D", "Gdzie jest twoja siostra?"),
|
||||
|
||||
# ==================== Тема 4: Food ====================
|
||||
("a1_food_l08_q1", "A", "Co jesz na śniadanie?"),
|
||||
("a1_food_l08_q1", "B", "Co pijesz rano?"),
|
||||
("a1_food_l08_q1", "C", "Kiedy jesz śniadanie?"),
|
||||
("a1_food_l08_q1", "D", "Czy lubisz śniadanie?"),
|
||||
|
||||
# ==================== Тема 5: Home ====================
|
||||
("a1_home_l09_q1", "A", "Ile masz pokoi?"),
|
||||
("a1_home_l09_q1", "B", "Gdzie jest twój pokój?"),
|
||||
("a1_home_l09_q1", "C", "Czy podoba ci się twój pokój?"),
|
||||
("a1_home_l09_q1", "D", "Jaki jest twój pokój?"),
|
||||
|
||||
# ==================== Тема 6: Numbers/Time ====================
|
||||
("a1_numbers_time_l05_q1", "A", "Która godzina?"),
|
||||
("a1_numbers_time_l05_q1", "B", "Jaki dziś dzień?"),
|
||||
("a1_numbers_time_l05_q1", "C", "Ile masz lat?"),
|
||||
("a1_numbers_time_l05_q1", "D", "Gdzie jesteś?"),
|
||||
|
||||
("a1_numbers_time_t04", "A", "Która godzina?"),
|
||||
("a1_numbers_time_t04", "B", "Jaki dziś dzień?"),
|
||||
("a1_numbers_time_t04", "C", "Ile masz lat?"),
|
||||
("a1_numbers_time_t04", "D", "Gdzie jesteś?"),
|
||||
|
||||
("a1_numbers_time_l06_q1", "A", "za piętnaście piąta"),
|
||||
("a1_numbers_time_l06_q1", "B", "kwadrans po czwartej"),
|
||||
("a1_numbers_time_l06_q1", "C", "wpół do piątej"),
|
||||
("a1_numbers_time_l06_q1", "D", "dokładnie piąta"),
|
||||
|
||||
("a1_numbers_time_l07_q1", "A", "O której godzinie?"),
|
||||
("a1_numbers_time_l07_q1", "B", "Która godzina?"),
|
||||
("a1_numbers_time_l07_q1", "C", "Jaki dziś dzień?"),
|
||||
("a1_numbers_time_l07_q1", "D", "Jak długo?"),
|
||||
|
||||
("a1_numbers_time_t05", "A", "O której godzinie?"),
|
||||
("a1_numbers_time_t05", "B", "Która godzina?"),
|
||||
("a1_numbers_time_t05", "C", "Jaki dziś dzień?"),
|
||||
("a1_numbers_time_t05", "D", "Jak długo?"),
|
||||
|
||||
# ==================== Тема 7: Colors/Clothes ====================
|
||||
("a1_colors_clothes_l09_q1", "A", "Jakiego koloru jest...?"),
|
||||
("a1_colors_clothes_l09_q1", "B", "Która godzina jest...?"),
|
||||
("a1_colors_clothes_l09_q1", "C", "Ile kosztuje...?"),
|
||||
("a1_colors_clothes_l09_q1", "D", "Gdzie jest...?"),
|
||||
|
||||
("a1_colors_clothes_t06", "A", "Jakiego koloru jest...?"),
|
||||
("a1_colors_clothes_t06", "B", "Która godzina jest...?"),
|
||||
("a1_colors_clothes_t06", "C", "Ile kosztuje...?"),
|
||||
("a1_colors_clothes_t06", "D", "Gdzie jest...?"),
|
||||
|
||||
# ==================== Тема 8: Weather/Seasons ====================
|
||||
("a1_weather_seasons_l09_q1", "A", "Jutro będzie padać deszcz."),
|
||||
("a1_weather_seasons_l09_q1", "B", "Wczoraj padał deszcz."),
|
||||
("a1_weather_seasons_l09_q1", "C", "Dziś pada deszcz."),
|
||||
("a1_weather_seasons_l09_q1", "D", "Jutro będzie zimno."),
|
||||
|
||||
("a1_weather_seasons_t06", "A", "Jutro będzie padać deszcz."),
|
||||
("a1_weather_seasons_t06", "B", "Wczoraj padał deszcz."),
|
||||
("a1_weather_seasons_t06", "C", "Dziś pada deszcz."),
|
||||
("a1_weather_seasons_t06", "D", "Jutro będzie zimno."),
|
||||
]
|
||||
|
||||
|
||||
async def main():
|
||||
pool = await asyncpg.create_pool(**DB_CONFIG)
|
||||
updated = 0
|
||||
not_found = []
|
||||
|
||||
async with pool.acquire() as conn:
|
||||
for question_id, option_key, correct_pl in FIXES:
|
||||
result = await conn.execute("""
|
||||
UPDATE question_options
|
||||
SET text_pl = $3
|
||||
WHERE question_id = $1 AND option_key = $2
|
||||
""", question_id, option_key, correct_pl)
|
||||
|
||||
# asyncpg возвращает строку вида "UPDATE 1" или "UPDATE 0"
|
||||
affected = int(result.split()[-1])
|
||||
if affected == 0:
|
||||
not_found.append((question_id, option_key))
|
||||
else:
|
||||
updated += affected
|
||||
|
||||
await pool.close()
|
||||
|
||||
print(f"✅ Обновлено записей: {updated} из {len(FIXES)}")
|
||||
if not_found:
|
||||
print(f"⚠️ Не найдено в БД (проверь question_id/option_key вручную):")
|
||||
for qid, key in not_found:
|
||||
print(f" - {qid} / {key}")
|
||||
else:
|
||||
print("🎉 Все записи найдены и обновлены.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user