mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Pollutants: Fix update for sceanrio.
This commit is contained in:
1 parent
f66d8c7a34
commit
6e79fe4cd5
1 file changed
+11
-7
@@ -107,11 +107,15 @@ class Pollutants(SQLSubModel):
|
|||||||
@classmethod
|
@classmethod
|
||||||
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(".")
|
||||||
|
created = False
|
||||||
|
|
||||||
if major == "0" and int(minor) <= 1:
|
if major == "0" and int(minor) <= 1:
|
||||||
if int(release) < 7:
|
if int(release) < 7:
|
||||||
cls._db_create(execute)
|
cls._db_create(execute)
|
||||||
|
created = True
|
||||||
|
|
||||||
elif major == "0" and int(minor) < 2:
|
if major == "0" and int(minor) < 2:
|
||||||
|
if not created:
|
||||||
cls._db_update_to_0_2_0(execute, data)
|
cls._db_update_to_0_2_0(execute, data)
|
||||||
cls._db_update_to_0_2_0_char(execute, data)
|
cls._db_update_to_0_2_0_char(execute, data)
|
||||||
|
|
||||||
@@ -125,12 +129,12 @@ class Pollutants(SQLSubModel):
|
|||||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||||
Scenario.update_db_add_scenario(execute, table)
|
Scenario.update_db_add_scenario(execute, table)
|
||||||
|
|
||||||
cls._db_create_lca(execute, ext="_tmp")
|
cls._db_create_pol(execute, ext="_tmp")
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
f"INSERT INTO {table_new}_tmp " +
|
f"INSERT INTO {table_new}_tmp " +
|
||||||
"(pamhyr_id, name, scenario) " +
|
"(pamhyr_id, name, scenario) " +
|
||||||
"SELECT pamhyr_id, name, scenario) " +
|
"SELECT pamhyr_id, name, scenario " +
|
||||||
f"FROM {table}"
|
f"FROM {table}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -145,7 +149,7 @@ class Pollutants(SQLSubModel):
|
|||||||
cls.update_db_add_pamhyr_id(execute, table, data)
|
cls.update_db_add_pamhyr_id(execute, table, data)
|
||||||
Scenario.update_db_add_scenario(execute, table)
|
Scenario.update_db_add_scenario(execute, table)
|
||||||
|
|
||||||
cls._db_create_lca(execute, ext="_tmp")
|
cls._db_create_pol_char(execute, ext="_tmp")
|
||||||
|
|
||||||
execute(
|
execute(
|
||||||
f"INSERT INTO {table_new}_tmp " +
|
f"INSERT INTO {table_new}_tmp " +
|
||||||
@@ -179,11 +183,11 @@ class Pollutants(SQLSubModel):
|
|||||||
|
|
||||||
if table is not None:
|
if table is not None:
|
||||||
for row in table:
|
for row in table:
|
||||||
id = row[0]
|
pid = row[0]
|
||||||
name = row[1]
|
name = row[1]
|
||||||
|
|
||||||
new_pollutant = cls(
|
new_pollutant = cls(
|
||||||
id=id, name=name,
|
id=pid, name=name,
|
||||||
status=status
|
status=status
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -191,7 +195,7 @@ class Pollutants(SQLSubModel):
|
|||||||
table = execute(
|
table = execute(
|
||||||
"SELECT * " +
|
"SELECT * " +
|
||||||
"FROM pollutants_characteristics " +
|
"FROM pollutants_characteristics " +
|
||||||
f"WHERE pollutant = {id}" +
|
f"WHERE pollutant = {pid} " +
|
||||||
f"AND scenario = {scenario.id} " +
|
f"AND scenario = {scenario.id} " +
|
||||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
|
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user