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,13 +73,16 @@ now = DateTime()\n ...@@ -73,13 +73,16 @@ 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
portal_type=\'Open Sale Order Line\',\n existing = len(portal.portal_catalog(\n
default_aggregate_uid=portal.restrictedTraverse(hosting_url).getUid()\n portal_type=\'Open Sale Order Line\',\n
)[0][0] > 0\n default_aggregate_uid=portal.restrictedTraverse(hosting_url).getUid(),\n
if hosting_url not in hosting_subscription_mapping and not existing:\n limit=1,\n
add_kw_kw[hosting_url] = add_kw.copy()\n )) > 0\n
add_kw_kw[hosting_url][\'explanation\'] = [\'Added because of %s \' % hosting_url]\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][\'explanation\'] = [\'Added because of %s \' % hosting_url]\n
\n \n
modify_kw_kw = {}\n modify_kw_kw = {}\n
for hosting_url, start_date in start_date_tuple_list:\n for hosting_url, start_date in start_date_tuple_list:\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