Commit be2c22f9 authored by Romain Courteaud's avatar Romain Courteaud

Prevent useless portal_catalog calls.

Fetching 1 element is faster than counting all.
parent c3bcb095
...@@ -73,11 +73,14 @@ now = DateTime()\n ...@@ -73,11 +73,14 @@ now = DateTime()\n
add_kw_kw = {}\n add_kw_kw = {}\n
for add_kw in add_kw_list:\n for add_kw in add_kw_list:\n
hosting_url = add_kw[\'aggregate\']\n hosting_url = add_kw[\'aggregate\']\n
existing = portal.portal_catalog.countResults(\n if hosting_url not in hosting_subscription_mapping:\n
existing = len(portal.portal_catalog(\n
portal_type=\'Open Sale Order Line\',\n portal_type=\'Open Sale Order Line\',\n
default_aggregate_uid=portal.restrictedTraverse(hosting_url).getUid()\n default_aggregate_uid=portal.restrictedTraverse(hosting_url).getUid(),\n
)[0][0] > 0\n limit=1,\n
if hosting_url not in hosting_subscription_mapping and not existing:\n )) > 0\n
if not existing:\n
# Hosting Subscription has never been related to any open order\n
add_kw_kw[hosting_url] = add_kw.copy()\n add_kw_kw[hosting_url] = add_kw.copy()\n
add_kw_kw[hosting_url][\'explanation\'] = [\'Added because of %s \' % hosting_url]\n add_kw_kw[hosting_url][\'explanation\'] = [\'Added because of %s \' % hosting_url]\n
\n \n
......
226 227
\ No newline at end of file \ No newline at end of file
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