Scenario: Add HS to memory clean and minor comment change.

disable_edition_parent_scenario
Pierre-Antoine 2026-05-21 15:05:17 +02:00
parent f9d83ac68c
commit 363b9c7132
2 changed files with 26 additions and 9 deletions

View File

@ -208,7 +208,7 @@ class Reach(SQLSubModel):
self.modified() self.modified()
def delete(self, indexes): def delete(self, indexes):
"""Delete some elements in profile list """Set some elements as deleted in profile list
Args: Args:
indexes: The list of index to delete indexes: The list of index to delete
@ -250,7 +250,7 @@ class Reach(SQLSubModel):
self.modified() self.modified()
def delete_profiles(self, profiles): def delete_profiles(self, profiles):
"""Delete some elements in profile list """Set profiles list as deleted
Args: Args:
profiles: The list of profile to delete profiles: The list of profile to delete

View File

@ -33,6 +33,12 @@ from Model.Status import StudyStatus
from Model.Except import NotImplementedMethodeError from Model.Except import NotImplementedMethodeError
from Model.River import River from Model.River import River
from Model.Geometry.Reach import Reach from Model.Geometry.Reach import Reach
from Model.HydraulicStructures.HydraulicStructures import (
HydraulicStructure
)
from Model.HydraulicStructures.Basic.HydraulicStructures import (
BasicHS
)
from Checker.Study import * from Checker.Study import *
@ -463,18 +469,29 @@ class Study(SQLModel):
@timer @timer
def memory_clean(self, ids): def memory_clean(self, ids):
if len(ids) == 0:
return
reach_class = Reach
hs_classes = [HydraulicStructure, BasicHS]
list_classes = set(PamhyrModelList.__subclasses__()) list_classes = set(PamhyrModelList.__subclasses__())
dict_classes = set(PamhyrModelDict.__subclasses__()) dict_classes = set(PamhyrModelDict.__subclasses__())
reach_class = Reach
def modifier(obj, data): def modifier(obj, data):
t = type(obj) t = type(obj)
if t in list_classes: if t is reach_class:
obj._lst = list( obj._profiles = list(
filter( filter(
lambda el: el.id not in ids, lambda el: el.id not in ids,
obj._lst obj._profiles
)
)
elif t in hs_classes:
obj._data = list(
filter(
lambda el: el.id not in ids,
obj._data
) )
) )
elif t in dict_classes: elif t in dict_classes:
@ -483,11 +500,11 @@ class Study(SQLModel):
if obj._dict[key].id not in ids: if obj._dict[key].id not in ids:
new[key] = obj._dict[key] new[key] = obj._dict[key]
obj._dict = new obj._dict = new
elif t is reach_class: elif t in list_classes:
obj._profiles = list( obj._lst = list(
filter( filter(
lambda el: el.id not in ids, lambda el: el.id not in ids,
obj._profiles obj._lst
) )
) )