diff --git a/routers/sentences.py b/routers/sentences.py index 9511304..871ba29 100644 --- a/routers/sentences.py +++ b/routers/sentences.py @@ -65,6 +65,7 @@ async def init_sentences(): ("B1", "sentences_b1.csv"), ] + offset = 0 for level, filename in level_files: sentences = load_sentences_from_csv(filename) for i, s in enumerate(sentences): @@ -74,11 +75,12 @@ async def init_sentences(): await conn.execute( """INSERT INTO sentences (sentence_number, sentence_pl, translation_ru, translation_uk, translation_en, difficulty, level) VALUES ($1, $2, $3, $4, $5, $6, $7) - ON CONFLICT (level, sentence_number) DO NOTHING""", - i + 1, s["sentence_pl"], + ON CONFLICT (sentence_number) DO NOTHING""", + offset + i + 1, s["sentence_pl"], s["translation_ru"], s["translation_uk"], s["translation_en"], difficulty, level ) + offset += len(sentences) def normalize_word_for_display(word: str) -> str: