mirror of https://gitlab.com/pamhyr/pamhyr2
Results: Continue db load method.
parent
3a3c4d9d73
commit
f0ccf1f4f7
|
|
@ -113,19 +113,22 @@ class Profile(SQLSubModel):
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
new = []
|
new = []
|
||||||
|
status = data['status']
|
||||||
|
|
||||||
study = data['study']
|
study = data['study']
|
||||||
status = data['status']
|
reach = data['reach']
|
||||||
|
profile = data['profile']
|
||||||
scenario = data["scenario"]
|
scenario = data["scenario"]
|
||||||
loaded = data['loaded_pid']
|
loaded = data['loaded_pid']
|
||||||
timestamps = data['timestamps']
|
timestamps = data['timestamps']
|
||||||
|
|
||||||
values = execute(
|
values = execute(
|
||||||
"SELECT pamhyr_id, result, key, " +
|
"SELECT pamhyr_id, result, key, " +
|
||||||
"reach, section, len_data, data, scenario " +
|
"len_data, data, scenario " +
|
||||||
"FROM results_data " +
|
"FROM results_data " +
|
||||||
f"WHERE scenario = {scenario.id} " +
|
f"WHERE scenario = {scenario.id} " +
|
||||||
f"AND pamhyr_id NOT IN ({', '.join(map(str, loaded))})"
|
f"AND reach = {reach.pamhyr_id} " +
|
||||||
|
f"AND section = {profile.pamhyr_id}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for v in values:
|
for v in values:
|
||||||
|
|
@ -134,16 +137,11 @@ class Profile(SQLSubModel):
|
||||||
pid = next(it)
|
pid = next(it)
|
||||||
result = next(it)
|
result = next(it)
|
||||||
key = next(it)
|
key = next(it)
|
||||||
reach = next(it)
|
|
||||||
section = next(it)
|
|
||||||
len_data = next(it)
|
len_data = next(it)
|
||||||
data = next(it)
|
data = next(it)
|
||||||
owner_scenario = next(it)
|
owner_scenario = next(it)
|
||||||
|
|
||||||
new_data = cls(
|
new_data = cls(profile, study)
|
||||||
id=pid, status=status,
|
|
||||||
owner_scenario=owner_scenario
|
|
||||||
)
|
|
||||||
|
|
||||||
sf = ">" + ''.join(itertools.repeat("f", len_data))
|
sf = ">" + ''.join(itertools.repeat("f", len_data))
|
||||||
values = struct.unpack(sf, data)
|
values = struct.unpack(sf, data)
|
||||||
|
|
@ -234,7 +232,19 @@ class Reach(SQLSubModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
return cls._db_load(execute, data)
|
reach = data["reach"]
|
||||||
|
|
||||||
|
new_reach = cls(
|
||||||
|
data["reach"], data["study"]
|
||||||
|
)
|
||||||
|
|
||||||
|
for profile in reach.profiles:
|
||||||
|
data["profile"] = profile
|
||||||
|
new_reach._profiles.append(
|
||||||
|
Profile._db_load(execute, data)
|
||||||
|
)
|
||||||
|
|
||||||
|
return new_reach
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
for profile in self._profiles:
|
for profile in self._profiles:
|
||||||
|
|
@ -293,7 +303,16 @@ class River(SQLSubModel):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _db_load(cls, execute, data=None):
|
def _db_load(cls, execute, data=None):
|
||||||
return cls._db_load(execute, data)
|
study = data["study"]
|
||||||
|
new_river = cls(study)
|
||||||
|
|
||||||
|
for reach in study.river.reachs():
|
||||||
|
data["reach"] = reach.reach
|
||||||
|
new_river._reachs.append(
|
||||||
|
Reach._db_load(execute, data)
|
||||||
|
)
|
||||||
|
|
||||||
|
return new_river
|
||||||
|
|
||||||
def _db_save(self, execute, data=None):
|
def _db_save(self, execute, data=None):
|
||||||
for reach in self._reachs:
|
for reach in self._reachs:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue