From ac4b93cd52f6a2980618c431d207cfe110d74caf Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Wed, 2 Jun 2021 02:38:31 +0200 Subject: [PATCH] =?UTF-8?q?Oprava=20case,=20impl=20=C5=99e=C5=A1itelsk?= =?UTF-8?q?=C3=BDch=20=C4=8Dl=C3=A1nk=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db_compare.py | 49 ++++++++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/db_compare.py b/db_compare.py index e58b6f11..6c13883b 100644 --- a/db_compare.py +++ b/db_compare.py @@ -324,20 +324,20 @@ def check_uloha(): def check_tema(): old_query = "SELECT * FROM seminar_problemy WHERE typ IN ('tema', 'serial') ORDER BY id" - new_query = """SELECT tema_typ, zad_text.na_web as text_zadani, res_text.na_web as text_reseni + new_query = """SELECT tema_typ, zad_text.na_web AS text_zadani, res_text.na_web AS text_reseni FROM seminar_temata -- Problém: JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id -- Text: -- TvCNode má dva potomky, oba TextNode. První drží původní text zadání, druhý řešení. - INNER JOIN seminar_nodes_temavcisle as tvcn ON tvcn.tema_id = id + INNER JOIN seminar_nodes_temavcisle AS tvcn ON tvcn.tema_id = id INNER JOIN seminar_nodes_treenode AS roottn ON tvcn.treenode_ptr_id = roottn.id INNER JOIN seminar_nodes_treenode AS zad_tn ON roottn.first_child_id = zad_tn.id INNER JOIN seminar_nodes_treenode AS res_tn ON zad_tn.succ_id = res_tn.id INNER JOIN seminar_nodes_obsah AS zad_on ON zad_on.treenode_ptr_id = zad_tn.id INNER JOIN seminar_nodes_obsah AS res_on ON res_on.treenode_ptr_id = res_tn.id - INNER JOIN seminar_texty as zad_text ON zad_on.text_id = zad_text.id - INNER JOIN seminar_texty as res_text ON res_on.text_id = res_text.id + INNER JOIN seminar_texty AS zad_text ON zad_on.text_id = zad_text.id + INNER JOIN seminar_texty AS res_text ON res_on.text_id = res_text.id ORDER BY problem_ptr_id""" same_fields = ['text_zadani', 'text_reseni'] @@ -356,7 +356,7 @@ def check_tema(): def check_konfera(): old_query = "SELECT * FROM seminar_problemy WHERE typ = 'konfera'" - new_query = "SELECT * FROM seminar_konfera JOIN seminar_problemy as problem ON problem_ptr_id = problem.id" + new_query = "SELECT * FROM seminar_konfera JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id" oldcur.execute(old_query) newcur.execute(new_query) @@ -373,20 +373,31 @@ def check_org_clanek(): raise ValueError('There exists a Org-clanek!') def check_res_clanek(): - return; # FIXME: Je vůbec co testovat? Ta tabulka obsahuje jen problem_ptr_id a cislo_id, které ale není nikde vyplněné. - #old_query = "SELECT * FROM seminar_problemy WHERE typ = 'res-clanek' ORDER BY id" - #new_query = "SELECT * FROM seminar_clanky JOIN seminar_problemy as problem ON problem_ptr_id = problem.id ORDER BY problem_ptr_id" - #same_fields = [] - #renamed_fields = [] - #old_fields = same_fields + [f[0] for f in renamed_fields] - #new_fields = same_fields + [f[1] for f in renamed_fields] - - #old_res, new_res = execute_simple(old_query, new_query) - #res = zip(old_res,new_res) - - #for o,n in res: - # check_same(o,n, old_fields, new_fields) - ## TODO: Cislo + # Dva(!) články mají text (zadání), který se má zachovat. + old_query = "SELECT * FROM seminar_problemy WHERE typ = 'res-clanek' ORDER BY id" + new_query = """SELECT cislo_id, text.na_web AS text_zadani + FROM seminar_clanky + 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_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 + + ORDER BY problem_ptr_id""" + same_fields = ['text_zadani'] + renamed_fields = [ + ('cislo_zadani_id', 'cislo_id'), + ] + old_fields = same_fields + [f[0] for f in renamed_fields] + new_fields = same_fields + [f[1] for f in renamed_fields] + + old_res, new_res = execute_simple(old_query, new_query) + res = zip(old_res,new_res) + + for o,n in res: + check_same(o,n, old_fields, new_fields) def check_untyped_problem(): old_query = "SELECT * FROM seminar_problemy WHERE typ NOT IN ('uloha', 'tema', 'serial', 'konfera', 'org-clanek', 'res-clanek')"