Commit b8d6257d authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_erp5: Speed up query when searchAndActivate

   Use child_aggregate is too slow on larger sets.
parent eb7d7ded
......@@ -2,9 +2,13 @@ from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
context.updateLocalRolesOnSecurityGroups()
document = context
if document.getPortalType() == "Upgrade Decision Line":
document = context.getParentValue()
if context.getPortalType() in ['Support Request', 'Upgrade Decision']:
document.updateLocalRolesOnSecurityGroups()
if document.getPortalType() in ['Support Request', 'Upgrade Decision']:
portal = context.getPortalObject()
if activate_kw is None:
......@@ -12,7 +16,7 @@ if context.getPortalType() in ['Support Request', 'Upgrade Decision']:
portal.portal_catalog.searchAndActivate(
portal_type=portal.getPortalEventTypeList(),
follow_up__uid=context.getUid(),
follow_up__uid=document.getUid(),
method_id="updateLocalRolesOnSecurityGroups",
activate_kw=activate_kw
)
......@@ -9,13 +9,12 @@ for object_ in internal_packing_list_line.getAggregateValueList(portal_type=port
object_.activate(after_path_and_method_id=after_tag).updateLocalRolesOnSecurityGroups()
if object_.getPortalType() == "Computer":
portal.portal_catalog.searchAndActivate(
portal_type=["Software Installation", "Support Request","Upgrade Decision"],
default_or_child_aggregate_uid=object_.getUid(),
portal_type=["Software Installation", "Support Request","Upgrade Decision Line"],
aggregate__uid=object_.getUid(),
method_id="Base_updateSlapOSLocalRolesOnSecurityGroups",
method_kw=dict(activate_kw={"after_path_and_method_id": after_tag}),
activate_kw={"after_path_and_method_id": after_tag}
)
elif object_.getPortalType() == "Hosting Subscription":
query = ComplexQuery(
ComplexQuery(
......@@ -23,8 +22,8 @@ for object_ in internal_packing_list_line.getAggregateValueList(portal_type=port
SimpleQuery(default_specialise_uid=object_.getUid()),
logical_operator="AND"),
ComplexQuery(
SimpleQuery(portal_type=["Support Request", "Upgrade Decision"]),
SimpleQuery(default_or_child_aggregate_uid=object_.getUid()),
SimpleQuery(portal_type=["Support Request", "Upgrade Decision Line"]),
SimpleQuery(aggregate__uid=object_.getUid()),
logical_operator="AND"),
logical_operator="OR"
)
......
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