Commit 13426916 authored by Julien Muchembled's avatar Julien Muchembled

Simulation: slightly speed up category testers

- Avoid overhead of getPropertyList & getXxx accessors
- Acquisition is useless for 'specialise' category on Simulation Movements.
  Maybe the same optimization can be done for all categories ?
parent d2b72fdb
...@@ -56,7 +56,8 @@ class CategoryMembershipEquivalenceTester(Predicate, EquivalenceTesterMixin): ...@@ -56,7 +56,8 @@ class CategoryMembershipEquivalenceTester(Predicate, EquivalenceTesterMixin):
@staticmethod @staticmethod
def _getTestedPropertyValue(movement, property): def _getTestedPropertyValue(movement, property):
return movement.getPropertyList(property) # What about using getCategoryMembershipList for Simulation Movements ?
return movement.getAcquiredCategoryMembershipList(property)
def _compare(self, prevision_movement, decision_movement): def _compare(self, prevision_movement, decision_movement):
""" """
......
...@@ -33,7 +33,7 @@ class SpecialiseEquivalenceTester(CategoryMembershipEquivalenceTester): ...@@ -33,7 +33,7 @@ class SpecialiseEquivalenceTester(CategoryMembershipEquivalenceTester):
""" """
The purpose of this divergence tester is to check the The purpose of this divergence tester is to check the
consistency between delivery movement and simulation movement consistency between delivery movement and simulation movement
for a specific category. for 'specialise' category.
""" """
meta_type = 'ERP5 Specialise Equivalence Tester' meta_type = 'ERP5 Specialise Equivalence Tester'
portal_type = 'Specialise Equivalence Tester' portal_type = 'Specialise Equivalence Tester'
...@@ -45,11 +45,10 @@ class SpecialiseEquivalenceTester(CategoryMembershipEquivalenceTester): ...@@ -45,11 +45,10 @@ class SpecialiseEquivalenceTester(CategoryMembershipEquivalenceTester):
def _getTestedPropertyValue(self, movement, property): def _getTestedPropertyValue(self, movement, property):
if movement.getPortalType() == 'Simulation Movement': if movement.getPortalType() == 'Simulation Movement':
return movement.getSpecialiseList() return movement.getCategoryMembershipList(property)
# following line would work for prevision movements, but it is slower # following line would work for prevision movements, but it is slower
kw = dict(
specialise_type_list=self.getMovementSpecialiseTypeList(),
exclude_specialise_type_list=self.getMovementExcludeSpecialiseTypeList(),
)
return [x.getRelativeUrl() return [x.getRelativeUrl()
for x in movement.getInheritedSpecialiseValueList(**kw)] for x in movement.getInheritedSpecialiseValueList(
self.getMovementSpecialiseTypeList(),
self.getMovementExcludeSpecialiseTypeList(),
)]
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