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
add_kw_kw = {}\n
for add_kw in add_kw_list:\n
hosting_url = add_kw[\'aggregate\']\n
existing = portal.portal_catalog.countResults(\n
portal_type=\'Open Sale Order Line\',\n
default_aggregate_uid=portal.restrictedTraverse(hosting_url).getUid()\n
)[0][0] > 0\n
if hosting_url not in hosting_subscription_mapping and not existing:\n
add_kw_kw[hosting_url] = add_kw.copy()\n
add_kw_kw[hosting_url][\'explanation\'] = [\'Added because of %s \' % hosting_url]\n
if hosting_url not in hosting_subscription_mapping:\n
existing = len(portal.portal_catalog(\n
portal_type=\'Open Sale Order Line\',\n
default_aggregate_uid=portal.restrictedTraverse(hosting_url).getUid(),\n
limit=1,\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][\'explanation\'] = [\'Added because of %s \' % hosting_url]\n
\n
modify_kw_kw = {}\n
for hosting_url, start_date in start_date_tuple_list:\n
......
226
\ No newline at end of file
227
\ 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