mirror of https://gitlab.com/pamhyr/pamhyr2
Adists: Fix update from id to pamhyr_id.
parent
2faebfd402
commit
0df813b0d2
|
|
@ -146,6 +146,30 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
execute(f"DROP TABLE {table}")
|
execute(f"DROP TABLE {table}")
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
|
||||||
|
cls._db_update_to_0_2_0_set_bca_pid(execute, data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_2_0_set_bca_pid(cls, execute, data):
|
||||||
|
pid_bca = data["id2pid"]["boundary_condition_adists"]
|
||||||
|
els = execute(
|
||||||
|
"SELECT pamhyr_id, bca " +
|
||||||
|
"FROM boundary_condition_data_adists"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
bca_id = next(it)
|
||||||
|
|
||||||
|
if bca_id == -1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE boundary_condition_data_adists " +
|
||||||
|
f"SET bca = {pid_bca[bca_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
new = []
|
new = []
|
||||||
|
|
|
||||||
|
|
@ -115,9 +115,9 @@ class D90AdisTSSpec(SQLSubModel):
|
||||||
for row in els:
|
for row in els:
|
||||||
it = iter(row)
|
it = iter(row)
|
||||||
pid = next(it)
|
pid = next(it)
|
||||||
pol_id = next(it)
|
d90_id = next(it)
|
||||||
|
|
||||||
if pol_id == -1:
|
if d90_id == -1:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
|
|
|
||||||
|
|
@ -121,15 +121,15 @@ class DIFAdisTSSpec(SQLSubModel):
|
||||||
def _db_update_to_0_2_0_set_dif_pid(cls, execute, data):
|
def _db_update_to_0_2_0_set_dif_pid(cls, execute, data):
|
||||||
pid_dif = data["id2pid"]["dif_adists"]
|
pid_dif = data["id2pid"]["dif_adists"]
|
||||||
els = execute(
|
els = execute(
|
||||||
f"SELECT pamhyr_id, dif FROM dif_adists_spec"
|
"SELECT pamhyr_id, dif FROM dif_adists_spec"
|
||||||
)
|
)
|
||||||
|
|
||||||
for row in els:
|
for row in els:
|
||||||
it = iter(row)
|
it = iter(row)
|
||||||
pid = next(it)
|
pid = next(it)
|
||||||
pol_id = next(it)
|
dif_id = next(it)
|
||||||
|
|
||||||
if pol_id == -1:
|
if dif_id == -1:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,29 @@ class ICAdisTSSpec(SQLSubModel):
|
||||||
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
|
execute(f"ALTER TABLE {table_new}_tmp RENAME TO {table_new}")
|
||||||
|
|
||||||
cls._db_update_to_0_2_0_set_reach_pid(execute, table_new, reachs)
|
cls._db_update_to_0_2_0_set_reach_pid(execute, table_new, reachs)
|
||||||
|
cls._db_update_to_0_2_0_set_ica_pid(execute, data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_2_0_set_ica_pid(cls, execute, data):
|
||||||
|
pid_ica = data["id2pid"]["initial_conditions_adist"]
|
||||||
|
els = execute(
|
||||||
|
"SELECT pamhyr_id, ic_default " +
|
||||||
|
"FROM initial_conditions_adists_spec"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
ica_id = next(it)
|
||||||
|
|
||||||
|
if ica_id == -1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE initial_conditions_adists_spec " +
|
||||||
|
f"SET ic_default = {pid_ica[ica_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,29 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
|
|
||||||
execute(f"DROP TABLE {table}")
|
execute(f"DROP TABLE {table}")
|
||||||
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
execute(f"ALTER TABLE {table}_tmp RENAME TO {table}")
|
||||||
|
cls._db_update_to_0_2_0_set_ica_pid(execute, data)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _db_update_to_0_2_0_set_lca_pid(cls, execute, data):
|
||||||
|
pid_lca = data["id2pid"]["lateral_contribution_adists"]
|
||||||
|
els = execute(
|
||||||
|
"SELECT pamhyr_id, lca " +
|
||||||
|
"FROM lateral_contribution_data_adists"
|
||||||
|
)
|
||||||
|
|
||||||
|
for row in els:
|
||||||
|
it = iter(row)
|
||||||
|
pid = next(it)
|
||||||
|
lca_id = next(it)
|
||||||
|
|
||||||
|
if lca_id == -1:
|
||||||
|
continue
|
||||||
|
|
||||||
|
execute(
|
||||||
|
f"UPDATE lateral_contribution_data_adists " +
|
||||||
|
f"SET lca = {pid_lca[lca_id]} " +
|
||||||
|
f"WHERE pamhyr_id = {pid}"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
|
|
|
||||||
|
|
@ -353,10 +353,6 @@ class SQLSubModel(PamhyrID):
|
||||||
if len(section) != 0:
|
if len(section) != 0:
|
||||||
section_id = section[0][0]
|
section_id = section[0][0]
|
||||||
|
|
||||||
logger.info(
|
|
||||||
f"Update reach rk {rk}({reach_id}) to pid {section_id}"
|
|
||||||
)
|
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
f"UPDATE {table} " +
|
f"UPDATE {table} " +
|
||||||
f"SET {section_column} = {section_id} " +
|
f"SET {section_column} = {section_id} " +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue