mirror of https://gitlab.com/pamhyr/pamhyr2
Compare commits
No commits in common. "a525d8a2b0f8a351896f5fa4f70a05f9b8382a7a" and "4ac86b9acb5bea90f4397411ee138774be34d21e" have entirely different histories.
a525d8a2b0
...
4ac86b9acb
|
|
@ -95,7 +95,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
if int(release) < 7:
|
if int(release) < 7:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
|
||||||
elif major == "0" and int(minor) < 2:
|
if major == "0" and int(minor) < 2:
|
||||||
cls._db_update_to_0_2_0(execute, data)
|
cls._db_update_to_0_2_0(execute, data)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
@ -149,7 +149,7 @@ class BoundaryConditionAdisTS(SQLSubModel):
|
||||||
new = []
|
new = []
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, pollutant, type, node " +
|
"SELECT id, pollutant, type, node " +
|
||||||
"FROM boundary_condition_adists"
|
"FROM boundary_condition_adists"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,11 @@ class BoundaryConditionsAdisTSList(PamhyrModelList):
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM boundary_condition_adists " +
|
"DELETE FROM boundary_condition_adists" +
|
||||||
f"WHERE scenario = {self._status.scenario_id}"
|
f"WHERE scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM boundary_condition_data_adists " +
|
"DELETE FROM boundary_condition_data_adists" +
|
||||||
f"WHERE scenario = {self._status.scenario_id}"
|
f"WHERE scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,7 @@ class D90AdisTS(SQLSubModel):
|
||||||
if int(release) < 6:
|
if int(release) < 6:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
|
||||||
elif major == "0" and int(minor) < 2:
|
if major == "0" and int(minor) < 2:
|
||||||
cls._db_update_to_0_2_0(execute, data)
|
cls._db_update_to_0_2_0(execute, data)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
@ -101,7 +101,7 @@ class D90AdisTS(SQLSubModel):
|
||||||
new = []
|
new = []
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, name, d90, enabled " +
|
"SELECT id, name, d90, enabled " +
|
||||||
"FROM d90_adists"
|
"FROM d90_adists"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -129,7 +129,7 @@ class D90AdisTS(SQLSubModel):
|
||||||
return new
|
return new
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
execute(f"DELETE FROM d90_adists WHERE pamhyr_id = {self.id}")
|
execute(f"DELETE FROM d90_adists WHERE id = {self.id}")
|
||||||
|
|
||||||
d90 = -1.
|
d90 = -1.
|
||||||
if self.d90 is not None:
|
if self.d90 is not None:
|
||||||
|
|
@ -138,7 +138,7 @@ class D90AdisTS(SQLSubModel):
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"d90_adists(" +
|
"d90_adists(" +
|
||||||
"pamhyr_id, name, d90, enabled" +
|
"id, name, d90, enabled" +
|
||||||
") " +
|
") " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.id}, '{self._db_format(self._name)}', " +
|
f"{self.id}, '{self._db_format(self._name)}', " +
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class D90AdisTSList(PamhyrModelList):
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM d90_adists " +
|
"DELETE FROM d90_adists" +
|
||||||
f"WHERE scenario = {self._status.scenario_id}"
|
f"WHERE scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ class DIFAdisTS(SQLSubModel):
|
||||||
if int(release) < 6:
|
if int(release) < 6:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
|
||||||
elif major == "0" and int(minor) < 2:
|
if major == "0" and int(minor) < 2:
|
||||||
cls._db_update_to_0_2_0(execute, data)
|
cls._db_update_to_0_2_0(execute, data)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
@ -107,7 +107,7 @@ class DIFAdisTS(SQLSubModel):
|
||||||
new = []
|
new = []
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, name, method, dif, b, c, enabled " +
|
"SELECT id, name, method, dif, b, c, enabled " +
|
||||||
"FROM dif_adists"
|
"FROM dif_adists"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ class DIFAdisTSList(PamhyrModelList):
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM dif_adists " +
|
"DELETE FROM dif_adists" +
|
||||||
f"WHERE scenario = {self._status.scenario_id}"
|
f"WHERE scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
if int(release) < 6:
|
if int(release) < 6:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
|
||||||
elif major == "0" and int(minor) < 2:
|
if major == "0" and int(minor) < 2:
|
||||||
cls._db_update_to_0_2_0(execute, data)
|
cls._db_update_to_0_2_0(execute, data)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
@ -99,10 +99,8 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
f"INSERT INTO {table}_tmp " +
|
f"INSERT INTO {table}_tmp " +
|
||||||
"(pamhyr_id, pollutant, name, concentration, " +
|
"(pamhyr_id, pollutant, reach, begin_rk, end_rk, scenario) " +
|
||||||
"eg, em, ed, scenario) " +
|
"SELECT pamhyr_id, pollutant, edge, begin_rk, end_rk, scenario) " +
|
||||||
"SELECT pamhyr_id, pollutant, name, concentration, " +
|
|
||||||
"eg, em, ed, scenario) " +
|
|
||||||
f"FROM {table}"
|
f"FROM {table}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -116,8 +114,8 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
new = []
|
new = []
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, pollutant, name, concentration, eg, em, ed, " +
|
"SELECT id, pollutant, name, concentration, eg, em, ed, " +
|
||||||
"enabled, scenario " +
|
"enabled " +
|
||||||
"FROM initial_conditions_adists"
|
"FROM initial_conditions_adists"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -178,7 +176,7 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"initial_conditions_adists(" +
|
"initial_conditions_adists(" +
|
||||||
"pamhyr_id, pollutant, name, concentration, " +
|
"id, pollutant, name, concentration, " +
|
||||||
"eg, em, ed, enabled" +
|
"eg, em, ed, enabled" +
|
||||||
") " +
|
") " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class InitialConditionsAdisTSList(PamhyrModelList):
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM initial_conditions_adists " +
|
"DELETE FROM initial_conditions_adists" +
|
||||||
f"WHERE scenario = {self._status.scenario_id}"
|
f"WHERE scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
if int(release) < 7:
|
if int(release) < 7:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
|
||||||
elif major == "0" and int(minor) < 2:
|
if major == "0" and int(minor) < 2:
|
||||||
cls._db_update_to_0_2_0(execute, data)
|
cls._db_update_to_0_2_0(execute, data)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
@ -153,12 +153,9 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
scenario = data["scenario"]
|
scenario = data["scenario"]
|
||||||
loaded = data['loaded_pid']
|
loaded = data['loaded_pid']
|
||||||
|
|
||||||
if scenario is None:
|
|
||||||
return new
|
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, pollutant, reach, begin_rk, end_rk " +
|
"SELECT id, pollutant, edge, begin_rk, end_rk " +
|
||||||
"FROM lateral_contribution_adists " +
|
"FROM lateral_contribution_adists" +
|
||||||
f"WHERE scenario = {scenario.id} " +
|
f"WHERE scenario = {scenario.id} " +
|
||||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
|
||||||
)
|
)
|
||||||
|
|
@ -176,8 +173,8 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
lca.end_rk = row[4]
|
lca.end_rk = row[4]
|
||||||
|
|
||||||
values = execute(
|
values = execute(
|
||||||
"SELECT data0, data1 " +
|
"SELECT data0," +
|
||||||
"FROM lateral_contribution_data_adists " +
|
" data1 FROM lateral_contribution_data_adists " +
|
||||||
f"WHERE scenario = {scenario.id} " +
|
f"WHERE scenario = {scenario.id} " +
|
||||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))}) "
|
||||||
f"AND lca = '{lca.id}'"
|
f"AND lca = '{lca.id}'"
|
||||||
|
|
@ -203,13 +200,13 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
f"DELETE FROM lateral_contribution_adists " +
|
f"DELETE FROM lateral_contribution_adists" +
|
||||||
f"WHERE pamhyr_id = {self.id} " +
|
f" WHERE id = {self.id} " +
|
||||||
f"AND scenario = {self._status.scenario_id}"
|
f"AND scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
execute(
|
execute(
|
||||||
f"DELETE FROM lateral_contribution_data_adists " +
|
f"DELETE FROM lateral_contribution_data_adists" +
|
||||||
f"WHERE lca = {self.id} " +
|
f" WHERE lc = {self.id} " +
|
||||||
f"AND scenario = {self._status.scenario_id}"
|
f"AND scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -231,7 +228,7 @@ class LateralContributionAdisTS(SQLSubModel):
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"lateral_contribution_data_adists(data0, data1, lca) " +
|
"lateral_contribution_data_adists(data0, data1, lc) " +
|
||||||
f"VALUES ('{data0}', {data1}, {self.id})"
|
f"VALUES ('{data0}', {data1}, {self.id})"
|
||||||
)
|
)
|
||||||
execute(sql)
|
execute(sql)
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,11 @@ class LateralContributionsAdisTSList(PamhyrModelList):
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM lateral_contribution_adists " +
|
"DELETE FROM lateral_contribution_adists" +
|
||||||
f"WHERE scenario = {self._status.scenario_id}"
|
f"WHERE scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM lateral_contribution_data_adists " +
|
"DELETE FROM lateral_contribution_data_adists" +
|
||||||
f"WHERE scenario = {self._status.scenario_id}"
|
f"WHERE scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ class OutputRKAdists(SQLSubModel):
|
||||||
if int(release) < 7:
|
if int(release) < 7:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
|
||||||
elif major == "0" and int(minor) <= 2:
|
if major == "0" and int(minor) <= 2:
|
||||||
if int(release) <= 0:
|
if int(release) <= 0:
|
||||||
cls._db_update_to_0_2_0(execute, data)
|
cls._db_update_to_0_2_0(execute, data)
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ class OutputRKAdists(SQLSubModel):
|
||||||
status = data["status"]
|
status = data["status"]
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT pamhyr_id, reach, rk, title " +
|
"SELECT id, reach, rk, title " +
|
||||||
f"FROM OutputRKAdists"
|
f"FROM OutputRKAdists"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ class OutputRKAdists(SQLSubModel):
|
||||||
|
|
||||||
sql = (
|
sql = (
|
||||||
"INSERT INTO " +
|
"INSERT INTO " +
|
||||||
"OutputRKAdists(pamhyr_id, reach, rk, title) " +
|
"OutputRKAdists(id, reach, rk, title) " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.id}, {self._reach}, {self._rk}, " +
|
f"{self.id}, {self._reach}, {self._rk}, " +
|
||||||
f"'{self._db_format(self._title)}'" +
|
f"'{self._db_format(self._title)}'" +
|
||||||
|
|
|
||||||
|
|
@ -39,8 +39,8 @@ class OutputRKAdistsList(PamhyrModelList):
|
||||||
|
|
||||||
# Delete previous data
|
# Delete previous data
|
||||||
execute(
|
execute(
|
||||||
"DELETE FROM OutputRKAdists " +
|
"DELETE FROM OutputRKAdists" +
|
||||||
f"WHERE scenario = {self._status.scenario_id}"
|
f"AND scenario = {self._status.scenario_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for sl in self._lst:
|
for sl in self._lst:
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,7 @@ class RiverNode(Node):
|
||||||
def _db_update(cls, execute, version, data=None):
|
def _db_update(cls, execute, version, data=None):
|
||||||
major, minor, release = version.strip().split(".")
|
major, minor, release = version.strip().split(".")
|
||||||
|
|
||||||
if major == "0" and int(minor) < 2:
|
if major == minor == "0":
|
||||||
cls._db_update_to_0_2_0(execute, data=data)
|
cls._db_update_to_0_2_0(execute, data=data)
|
||||||
|
|
||||||
if major == "0" and minor == "1":
|
if major == "0" and minor == "1":
|
||||||
|
|
|
||||||
|
|
@ -277,10 +277,10 @@ class Study(SQLModel):
|
||||||
"INSERT INTO info VALUES ('study_release', '0')"
|
"INSERT INTO info VALUES ('study_release', '0')"
|
||||||
)
|
)
|
||||||
|
|
||||||
if major == "0" and int(minor) <= 2:
|
if major == "0" and int(minor) <= 1:
|
||||||
self._add_into_info_if_not_exists('current_scenario', '0')
|
self._add_into_info_if_not_exists('current_scenario', '0')
|
||||||
|
|
||||||
if major == "0" and int(minor) < 2:
|
if major == "0" and int(minor) < 1:
|
||||||
# Need to temporary disable the sqlite foreign keys
|
# Need to temporary disable the sqlite foreign keys
|
||||||
# checking to update db dans change the table id fk to
|
# checking to update db dans change the table id fk to
|
||||||
# table pamhyr_id fk
|
# table pamhyr_id fk
|
||||||
|
|
@ -290,7 +290,7 @@ class Study(SQLModel):
|
||||||
|
|
||||||
ok = self._update_submodel(version[0], data={})
|
ok = self._update_submodel(version[0], data={})
|
||||||
|
|
||||||
if major == "0" and int(minor) < 2:
|
if major == "0" and int(minor) < 1:
|
||||||
# Reactivate foreign keys checking
|
# Reactivate foreign keys checking
|
||||||
self.execute(
|
self.execute(
|
||||||
"PRAGMA foreign_keys = ON;"
|
"PRAGMA foreign_keys = ON;"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue