mirror of https://gitlab.com/pamhyr/pamhyr2
Adists: Scenario: Minor fix.
parent
d7fcf62e12
commit
a525d8a2b0
|
|
@ -101,7 +101,7 @@ class D90AdisTS(SQLSubModel):
|
||||||
new = []
|
new = []
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT id, name, d90, enabled " +
|
"SELECT pamhyr_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 id = {self.id}")
|
execute(f"DELETE FROM d90_adists WHERE pamhyr_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(" +
|
||||||
"id, name, d90, enabled" +
|
"pamhyr_id, name, d90, enabled" +
|
||||||
") " +
|
") " +
|
||||||
"VALUES (" +
|
"VALUES (" +
|
||||||
f"{self.id}, '{self._db_format(self._name)}', " +
|
f"{self.id}, '{self._db_format(self._name)}', " +
|
||||||
|
|
|
||||||
|
|
@ -107,7 +107,7 @@ class DIFAdisTS(SQLSubModel):
|
||||||
new = []
|
new = []
|
||||||
|
|
||||||
table = execute(
|
table = execute(
|
||||||
"SELECT id, name, method, dif, b, c, enabled " +
|
"SELECT pamhyr_id, name, method, dif, b, c, enabled " +
|
||||||
"FROM dif_adists"
|
"FROM dif_adists"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,10 @@ class InitialConditionsAdisTS(SQLSubModel):
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
f"INSERT INTO {table}_tmp " +
|
f"INSERT INTO {table}_tmp " +
|
||||||
"(pamhyr_id, pollutant, name, concentration, eg, em, ed, scenario) " +
|
"(pamhyr_id, pollutant, name, concentration, " +
|
||||||
"SELECT pamhyr_id, pollutant, name, concentration, eg, em, ed, scenario) " +
|
"eg, em, ed, scenario) " +
|
||||||
|
"SELECT pamhyr_id, pollutant, name, concentration, " +
|
||||||
|
"eg, em, ed, scenario) " +
|
||||||
f"FROM {table}"
|
f"FROM {table}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -153,6 +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 pamhyr_id, pollutant, reach, begin_rk, end_rk " +
|
||||||
"FROM lateral_contribution_adists " +
|
"FROM lateral_contribution_adists " +
|
||||||
|
|
|
||||||
|
|
@ -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 == minor == "0":
|
if major == "0" and int(minor) < 2:
|
||||||
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) <= 1:
|
if major == "0" and int(minor) <= 2:
|
||||||
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) < 1:
|
if major == "0" and int(minor) < 2:
|
||||||
# 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) < 1:
|
if major == "0" and int(minor) < 2:
|
||||||
# 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