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):
document returned by catalog) as first positional argument.
Use 'packet_size' parameter to limit the size of each group (default: 30).
'activity_count' parameter is deprecated.
Its value should be hardcoded because CMFActivity can now handle many
activities efficiently and any tweak should benefit to everyone.
However, there are still rare cases where one want to limit the number
of processing nodes, to minimize latency of high-priority activities.
The maximum number of activities that are generated by this method
(before activating itself) can be tweaked with 'activity_count'.
Except as a way to limit the number of processing nodes, this should be
rarely used because CMFActivity can handle many activities efficiently
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()
select_method_id = catalog_kw.pop('select_method_id', None)
limit = catalog_kw.pop('activity_count', 0)
if select_method_id:
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
assert not group_kw, (kw, group_kw)
packet_size = catalog_kw.pop('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:
group_method_cost = group_kw.get('group_method_cost', .034) # 30 objects
limit = catalog_kw.pop('activity_count', None) or \
100 * int(ceil(1 / group_method_cost))
if limit == 0:
limit = 100 * int(ceil(1 / group_method_cost))
if min_uid:
catalog_kw['min_uid'] = SimpleQuery(uid=min_uid,
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