Results: Fix db save results open and display.

This commit is contained in:
parouby committed 2025-09-25 10:58:29 +02:00
1 parent 9375827949
commit dbcdace348
5 files changed
+31 -9

No files matched your search

+16 -7
View File
@@ -111,7 +111,7 @@ class Profile(SQLSubModel):
@classmethod
def _db_load(cls, execute, data=None):
new = []
new = {}
status = data['status']
study = data['study']
@@ -140,18 +140,27 @@ class Profile(SQLSubModel):
data = next(it)
owner_scenario = next(it)
new_data = cls(profile, study)
if profile not in new:
new_data = cls(profile, study)
new[profile] = new_data
else:
new_data = new[profile]
sf = ">" + ''.join(itertools.repeat("f", len_data))
values = struct.unpack(sf, data)
for timestamp, value in zip(timestamps, values):
new_data.set(timestamp, key, value)
if key == "Z":
new_data.update_water_limits(timestamp, value)
loaded.add(pid)
new.append(new_data)
return list(new.values())
return new
def update_water_limits(self, timestamp, z):
limits = self.geometry.get_water_limits(z)
self.set(
timestamp, "water_limits", limits
)
def get_keys(self):
return reduce(
@@ -250,10 +259,10 @@ class Reach(SQLSubModel):
reach = data["reach"]
new_reach = cls(
data["reach"], data["study"]
data["reach"], data["study"], with_init=False
)
for profile in reach.profiles:
for i, profile in enumerate(reach.profiles):
data["profile"] = profile
new_reach._profiles += Profile._db_load(execute, data)
+8
View File
@@ -527,3 +527,11 @@ class Study(SQLModel):
self.status.set_as_editable()
return new
@property
def results(self):
return self._river._results
@results.setter
def results(self, results):
self._river._results = results