Commit 6b2e0b92 authored by Julien Muchembled's avatar Julien Muchembled

searchAndActivate: rework 'activity_count' parameter

- It's not deprecated anymore.
- When activities are grouped at CMFActivity level, it specifies a number of
  activities that are generated at a time instead of a number of activity
  groups.
- The special None value means no limit.
parent c42c1d38
...@@ -1349,26 +1349,33 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject): ...@@ -1349,26 +1349,33 @@ class CatalogTool (UniqueObject, ZCatalog, CMFCoreCatalogTool, ActiveObject):
document returned by catalog) as first positional argument. document returned by catalog) as first positional argument.
Use 'packet_size' parameter to limit the size of each group (default: 30). Use 'packet_size' parameter to limit the size of each group (default: 30).
'activity_count' parameter is deprecated. The maximum number of activities that are generated by this method
Its value should be hardcoded because CMFActivity can now handle many (before activating itself) can be tweaked with 'activity_count'.
activities efficiently and any tweak should benefit to everyone. Except as a way to limit the number of processing nodes, this should be
However, there are still rare cases where one want to limit the number rarely used because CMFActivity can handle many activities efficiently
of processing nodes, to minimize latency of high-priority activities. and we should rather have good default values.
The special None value means no limit, which can be useful when a catalog
search is so slow and doesn't return too many results.
'packet_size' is deprecated when used without 'select_method_id'.
""" """
catalog_kw = kw.copy() catalog_kw = kw.copy()
select_method_id = catalog_kw.pop('select_method_id', None) select_method_id = catalog_kw.pop('select_method_id', None)
limit = catalog_kw.pop('activity_count', 0)
if select_method_id: if select_method_id:
packet_size = catalog_kw.pop('packet_size', 30) packet_size = catalog_kw.pop('packet_size', 30)
limit = packet_size * catalog_kw.pop('activity_count', 100) if limit is not None:
limit = packet_size * (limit or 100)
elif 'packet_size' in catalog_kw: # BBB elif 'packet_size' in catalog_kw: # BBB
assert not group_kw, (kw, group_kw) assert not group_kw, (kw, group_kw)
packet_size = catalog_kw.pop('packet_size') packet_size = catalog_kw.pop('packet_size')
group_method_cost = 1. / packet_size group_method_cost = 1. / packet_size
limit = packet_size * catalog_kw.pop('activity_count', 100) if limit == 0:
limit = 100 * packet_size
else: else:
group_method_cost = group_kw.get('group_method_cost', .034) # 30 objects group_method_cost = group_kw.get('group_method_cost', .034) # 30 objects
limit = catalog_kw.pop('activity_count', None) or \ if limit == 0:
100 * int(ceil(1 / group_method_cost)) limit = 100 * int(ceil(1 / group_method_cost))
if min_uid: if min_uid:
catalog_kw['min_uid'] = SimpleQuery(uid=min_uid, catalog_kw['min_uid'] = SimpleQuery(uid=min_uid,
comparison_operator='>') comparison_operator='>')
......
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