Commit e99e166f authored by Julien Muchembled's avatar Julien Muchembled

Speed up Delivery.expand by not expanding the same Applied Rule several times

parent 0c5fe26d
...@@ -819,18 +819,17 @@ class Delivery(XMLObject, ImmobilisationDelivery, ...@@ -819,18 +819,17 @@ class Delivery(XMLObject, ImmobilisationDelivery,
exclude_rule_path : do not expand this applied rule (or children exclude_rule_path : do not expand this applied rule (or children
applied rule) applied rule)
""" """
if excluded_rule_path_list is None: excluded_rule_path_list = set(excluded_rule_path_list or ())
excluded_rule_path_list = [] to_expand = sorted(set(sm.getParentValue()
to_expand_list = [] for sm in self._getAllRelatedSimulationMovementList()
for sim_movement in self._getAllRelatedSimulationMovementList(): if sm.getRootAppliedRule().getPath() not in excluded_rule_path_list),
if sim_movement.getRootAppliedRule().getPath() \ key=lambda x: x.getRelativeUrl())
not in excluded_rule_path_list: prev_ar = None
parent_value = sim_movement.getParentValue() for ar in to_expand:
if parent_value not in to_expand_list: if not ar.aq_inContextOf(prev_ar):
to_expand_list.append(parent_value) ar.expand(activate_kw=activate_kw, **kw)
for rule in to_expand_list: ar.recursiveReindexSimulationMovement(activate_kw=activate_kw)
rule.expand(activate_kw=activate_kw, **kw) prev_ar = ar
rule.recursiveReindexSimulationMovement(activate_kw=activate_kw)
security.declareProtected( Permissions.AccessContentsInformation, security.declareProtected( Permissions.AccessContentsInformation,
'getRootCausalityValueList') 'getRootCausalityValueList')
...@@ -966,14 +965,11 @@ class Delivery(XMLObject, ImmobilisationDelivery, ...@@ -966,14 +965,11 @@ class Delivery(XMLObject, ImmobilisationDelivery,
return disconnected_simulation_movement_list return disconnected_simulation_movement_list
def _getAllRelatedSimulationMovementList(self, **kw): def _getAllRelatedSimulationMovementList(self, **kw):
search_method = \
self.getPortalObject().portal_catalog.unrestrictedSearchResults
movement_uid_list = [x.getUid() for x in self.getMovementList()] movement_uid_list = [x.getUid() for x in self.getMovementList()]
if len(movement_uid_list) == 0: return movement_uid_list and \
return [] self.getPortalObject().portal_catalog.unrestrictedSearchResults(
sim_movement_list = search_method(portal_type='Simulation Movement', portal_type='Simulation Movement',
delivery_uid=movement_uid_list, **kw) delivery_uid=movement_uid_list, **kw)
return sim_movement_list
def getDivergentTesterAndSimulationMovementList(self): def getDivergentTesterAndSimulationMovementList(self):
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment