From 9d7276578ad869db768981b7890c85447857fe80 Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Tue, 8 Jun 2021 23:36:13 +0200 Subject: [PATCH 1/3] Bugfixy v migracich a kontrolach. --- db_compare.py | 24 +++++++++---------- seminar/migrations/0049_auto_20190430_2354.py | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/db_compare.py b/db_compare.py index 2d4e9c16..4cfe7659 100644 --- a/db_compare.py +++ b/db_compare.py @@ -310,24 +310,24 @@ def check_problem_common(): def check_uloha(): old_query = "SELECT * FROM seminar_problemy WHERE typ = 'uloha' ORDER BY id" - new_query = """SELECT cislo_zadani, cislo_reseni, problem_ptr_id, max_body, uzt.na_web AS text_zadani, uvt.na_web AS text_reseni + new_query = """SELECT cislo_zadani_id, cislo_reseni_id, problem_ptr_id, max_body, uzt.na_web AS text_zadani, uvt.na_web AS text_reseni FROM seminar_ulohy -- Problém: JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id -- Text zadání: - INNER JOIN seminar_nodes_uloha_zadani AS uzn ON id = uzn.uloha_id + INNER JOIN seminar_nodes_uloha_zadani AS uzn ON problem.id = uzn.uloha_id INNER JOIN seminar_nodes_treenode AS uztn ON uztn.id = uzn.treenode_ptr_id INNER JOIN seminar_nodes_obsah AS uzo ON uzo.treenode_ptr_id = uztn.first_child_id INNER JOIN seminar_texty AS uzt ON uzo.text_id = uzt.id -- Text vzoráku: - INNER JOIN seminar_nodes_uloha_zadani AS uvn ON id = uvn.uloha_id + INNER JOIN seminar_nodes_uloha_zadani AS uvn ON problem.id = uvn.uloha_id INNER JOIN seminar_nodes_treenode AS uvtn ON uvtn.id = uvn.treenode_ptr_id INNER JOIN seminar_nodes_obsah AS uvo ON uvo.treenode_ptr_id = uvtn.first_child_id INNER JOIN seminar_texty AS uvt ON uvo.text_id = uvt.id ORDER BY problem_ptr_id""" - same_fields = ['cislo_zadani', 'cislo_reseni', 'text_zadani', 'text_reseni'] + same_fields = ['cislo_zadani_id', 'cislo_reseni_id', 'text_zadani', 'text_reseni'] renamed_fields = [ ('id', 'problem_ptr_id'), ('body', 'max_body'), @@ -349,7 +349,7 @@ def check_tema(): FROM seminar_problemy INNER JOIN seminar_cisla AS c ON c.id = cislo_zadani_id WHERE typ IN ('tema', 'serial') - ORDER BY id""" + ORDER BY seminar_problemy.id""" new_query = """SELECT tema_typ, zad_text.na_web AS text_zadani, res_text.na_web AS text_reseni, rn.rocnik_id AS rocnik_id FROM seminar_temata -- Problém: @@ -408,10 +408,10 @@ def check_res_clanek(): JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id INNER JOIN seminar_hodnoceni AS hodn ON problem.id = hodn.problem_id INNER JOIN seminar_reseni AS rese ON rese.id = hodn.reseni_id - INNER JOIN seminar_nodes_reseni AS resnode ON resnode.reseni_id = rese.id + INNER JOIN seminar_nodes_otistene_reseni AS resnode ON resnode.reseni_id = rese.id INNER JOIN seminar_nodes_treenode AS tn ON resnode.treenode_ptr_id = tn.id - INNER JOIN seminar_nodes_obsah AS on ON on.treenode_ptr_id = tn.first_child_id - INNER JOIN seminar_texty AS text ON text.id = on.text_id + INNER JOIN seminar_nodes_obsah AS son ON son.treenode_ptr_id = tn.first_child_id + INNER JOIN seminar_texty AS text ON text.id = son.text_id ORDER BY problem_ptr_id""" same_fields = ['text_zadani'] @@ -451,10 +451,10 @@ check_nastaveni() check_novinky() check_pohadka() -check_problem_common() -check_uloha() -check_tema() +#check_problem_common() - RUZNE POCTY RADKU +#check_uloha() - RUNE POCTY RADKU +#check_tema() - RUZNE POCTY RADKU check_konfera() check_org_clanek() -check_res_clanek() +#check_res_clanek() - RUZNE POCTY RADKU check_untyped_problem() diff --git a/seminar/migrations/0049_auto_20190430_2354.py b/seminar/migrations/0049_auto_20190430_2354.py index 985b3531..8abe0460 100644 --- a/seminar/migrations/0049_auto_20190430_2354.py +++ b/seminar/migrations/0049_auto_20190430_2354.py @@ -63,7 +63,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(primary_key=True, serialize=False)), ('jmeno', models.CharField(max_length=256, verbose_name='jméno')), ('prijmeni', models.CharField(max_length=256, verbose_name='příjmení')), - ('prezdivka', models.CharField(max_length=256, verbose_name='přezdívka')), + ('prezdivka', models.CharField(max_length=256, verbose_name='přezdívka', blank=True, null=False)), ('pohlavi_muz', models.BooleanField(default=False, verbose_name='pohlaví (muž)')), ('email', models.EmailField(blank=True, default='', max_length=256, verbose_name='e-mail')), ('telefon', models.CharField(blank=True, default='', max_length=256, verbose_name='telefon')), From 34937391ff12d87d5d556136eaeb36154c1c33c4 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 8 Jun 2021 23:39:43 +0200 Subject: [PATCH 2/3] =?UTF-8?q?Poh=C3=A1dka=20otestov=C3=A1na?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db_compare.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/db_compare.py b/db_compare.py index 4cfe7659..a6013723 100644 --- a/db_compare.py +++ b/db_compare.py @@ -254,12 +254,19 @@ def check_novinky(): def check_pohadka(): old_query = "SELECT * FROM seminar_pohadky ORDER BY id" - new_query = """SELECT sp.id AS id, sp.autor_id AS autor_id, sp.vytvoreno AS vytvoreno, snp.treenode_ptr_id AS treenode_ptr_id, st.na_web AS text + new_query = """SELECT sp.id AS id, sp.autor_id AS autor_id, sp.vytvoreno AS vytvoreno, snp.treenode_ptr_id AS treenode_ptr_id, st.na_web AS text, + zn_pred.uloha_id AS uloha_pred, zn_po.uloha_id AS uloha_po FROM seminar_pohadky AS sp + -- Text pohádky INNER JOIN seminar_nodes_pohadka AS snp ON sp.id = snp.pohadka_id INNER JOIN seminar_nodes_treenode AS snt ON snt.id = snp.treenode_ptr_id INNER JOIN seminar_nodes_obsah AS sno ON sno.treenode_ptr_id = snt.first_child_id INNER JOIN seminar_texty AS st ON sno.text_id = st.id + -- Predchozí úloha + LEFT OUTER JOIN seminar_nodes_treenode AS ztn_pred ON ztn_pred.succ_id = snt.id + INNER JOIN seminar_nodes_uloha AS zn_pred ON zn_pred.treenode_ptr_id = ztn_pred.id + -- Následující úloha + LEFT OUTER JOIN seminar_nodes_uloha_zadani AS zn_po ON zn_po.treenode_ptr_id = snt.succ_id ORDER BY sp.id""" @@ -271,6 +278,10 @@ def check_pohadka(): if o['autor_id'] is not None: if get_user_id_for_org_id(n['autor_id']) != o['autor_id']: raise ValueError("Nesedi autori u pohadky") + # Správné úlohy + spravny_klic = 'uloha_pred' if o['pred'] else 'uloha_po' + if o['uloha_id'] != n[spravny_klic]: + raise ValueError(f"Pohádka přidružená ke špatné úloze! old: {o['uloha_id']}, new: {n[spravny_klic]}, pozice: {spravny_klic}") # Problémy jsou rozdělené podle typů: From 49b3174a6241e7bb3d904466311c6e0395ae82a5 Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Tue, 8 Jun 2021 23:51:12 +0200 Subject: [PATCH 3/3] Bugfixy. --- db_compare.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db_compare.py b/db_compare.py index a6013723..3eab02a7 100644 --- a/db_compare.py +++ b/db_compare.py @@ -264,7 +264,7 @@ def check_pohadka(): INNER JOIN seminar_texty AS st ON sno.text_id = st.id -- Predchozí úloha LEFT OUTER JOIN seminar_nodes_treenode AS ztn_pred ON ztn_pred.succ_id = snt.id - INNER JOIN seminar_nodes_uloha AS zn_pred ON zn_pred.treenode_ptr_id = ztn_pred.id + LEFT OUTER JOIN seminar_nodes_uloha_zadani AS zn_pred ON zn_pred.treenode_ptr_id = ztn_pred.id -- Následující úloha LEFT OUTER JOIN seminar_nodes_uloha_zadani AS zn_po ON zn_po.treenode_ptr_id = snt.succ_id @@ -462,10 +462,10 @@ check_nastaveni() check_novinky() check_pohadka() -#check_problem_common() - RUZNE POCTY RADKU -#check_uloha() - RUNE POCTY RADKU -#check_tema() - RUZNE POCTY RADKU +check_problem_common() +check_uloha() +check_tema() check_konfera() check_org_clanek() -#check_res_clanek() - RUZNE POCTY RADKU +check_res_clanek() check_untyped_problem()