Browse Source

Oprava case, impl řešitelských článků

middleware_test
Pavel "LEdoian" Turinsky 4 years ago
parent
commit
ac4b93cd52
  1. 49
      db_compare.py

49
db_compare.py

@ -324,20 +324,20 @@ def check_uloha():
def check_tema(): def check_tema():
old_query = "SELECT * FROM seminar_problemy WHERE typ IN ('tema', 'serial') ORDER BY id" 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 FROM seminar_temata
-- Problém: -- Problém:
JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id
-- Text: -- Text:
-- TvCNode dva potomky, oba TextNode. První drží původní text zadání, druhý řešení. -- TvCNode 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 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 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_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 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_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 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 res_text ON res_on.text_id = res_text.id
ORDER BY problem_ptr_id""" ORDER BY problem_ptr_id"""
same_fields = ['text_zadani', 'text_reseni'] same_fields = ['text_zadani', 'text_reseni']
@ -356,7 +356,7 @@ def check_tema():
def check_konfera(): def check_konfera():
old_query = "SELECT * FROM seminar_problemy WHERE typ = '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) oldcur.execute(old_query)
newcur.execute(new_query) newcur.execute(new_query)
@ -373,20 +373,31 @@ def check_org_clanek():
raise ValueError('There exists a Org-clanek!') raise ValueError('There exists a Org-clanek!')
def check_res_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é. # Dva(!) články mají text (zadání), který se má zachovat.
#old_query = "SELECT * FROM seminar_problemy WHERE typ = 'res-clanek' ORDER BY id" 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" new_query = """SELECT cislo_id, text.na_web AS text_zadani
#same_fields = [] FROM seminar_clanky
#renamed_fields = [] JOIN seminar_problemy AS problem ON problem_ptr_id = problem.id
#old_fields = same_fields + [f[0] for f in renamed_fields] INNER JOIN seminar_hodnoceni AS hodn ON problem.id = hodn.problem_id
#new_fields = same_fields + [f[1] for f in renamed_fields] 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
#old_res, new_res = execute_simple(old_query, new_query) INNER JOIN seminar_nodes_treenode AS tn ON resnode.treenode_ptr_id = tn.id
#res = zip(old_res,new_res) 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
#for o,n in res:
# check_same(o,n, old_fields, new_fields) ORDER BY problem_ptr_id"""
## TODO: Cislo 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(): def check_untyped_problem():
old_query = "SELECT * FROM seminar_problemy WHERE typ NOT IN ('uloha', 'tema', 'serial', 'konfera', 'org-clanek', 'res-clanek')" old_query = "SELECT * FROM seminar_problemy WHERE typ NOT IN ('uloha', 'tema', 'serial', 'konfera', 'org-clanek', 'res-clanek')"

Loading…
Cancel
Save