Oprava case, impl řešitelských článků
This commit is contained in:
parent
3ffbe08e67
commit
ac4b93cd52
1 changed files with 28 additions and 17 deletions
|
@ -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]
|
||||
# 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
|
||||
|
||||
#old_res, new_res = execute_simple(old_query, new_query)
|
||||
#res = zip(old_res,new_res)
|
||||
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]
|
||||
|
||||
#for o,n in res:
|
||||
# check_same(o,n, old_fields, new_fields)
|
||||
## TODO: Cislo
|
||||
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')"
|
||||
|
|
Loading…
Reference in a new issue