Result: Fix db load profiles list.

scenarios
Pierre-Antoine 2025-09-23 17:09:11 +02:00
parent 26d1d63edb
commit 5f5a47679d
1 changed files with 9 additions and 9 deletions

View File

@ -196,7 +196,7 @@ class Profile(SQLSubModel):
class Reach(SQLSubModel): class Reach(SQLSubModel):
_sub_classes = [Profile] _sub_classes = [Profile]
def __init__(self, reach, study): def __init__(self, reach, study, with_init=True):
super(Reach, self).__init__( super(Reach, self).__init__(
id=-1, status=study.status, id=-1, status=study.status,
owner_scenario=study.status.scenario.id owner_scenario=study.status.scenario.id
@ -204,12 +204,14 @@ class Reach(SQLSubModel):
self._study = study self._study = study
self._reach = reach # Source reach in the study self._reach = reach # Source reach in the study
self._profiles = list( self._profiles = []
map( if with_init:
lambda p: Profile(p, self._study), self._profiles = list(
reach.profiles map(
lambda p: Profile(p, self._study),
reach.profiles
)
) )
)
def __len__(self): def __len__(self):
return len(self._profiles) return len(self._profiles)
@ -253,9 +255,7 @@ class Reach(SQLSubModel):
for profile in reach.profiles: for profile in reach.profiles:
data["profile"] = profile data["profile"] = profile
new_reach._profiles.append( new_reach._profiles += Profile._db_load(execute, data)
Profile._db_load(execute, data)
)
return new_reach return new_reach