Commit 2c6004f5 authored by Romain Courteaud's avatar Romain Courteaud

Use modification_date to reduce checking too many object in case of massive reindex.

Use query syntax.
parent 1a2e1450
......@@ -50,34 +50,31 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
if params is None:\n
<value> <string>if params is None:\n
params = {}\n
kw = {}\n
\n
from DateTime import DateTime\n
from Products.ZSQLCatalog.SQLCatalog import Query\n
\n
last_active_process = context.getLastActiveProcess()\n
if last_active_process is not None and params.get(\'full\', False):\n
# fetch only objects modified since last alarm run\n
kw[\'indexation_timestamp\'] = \'>= %s\' % last_active_process.getStartDate().ISO()\n
kw[\'modification_date\'] = Query(modification_date=last_active_process.getStartDate(), range="min")\n
\n
# register active process in order to have "windows" of last indexed objects\n
context.newActiveProcess()\n
\n
context.getPortalObject().portal_catalog.searchAndActivate(\n
method_id=\'Person_storeOpenOrderJournal\',\n
method_kw={\'indexation_timestamp\': kw.get(\'indexation_timestamp\'), \'tag\': tag, \'stop_date\': params.get(\'stop_date\')},\n
method_kw={\'modification_date\': kw.get(\'modification_date\'), \'tag\': tag, \'stop_date\': params.get(\'stop_date\')},\n
activate_kw={\'tag\': tag, \'priority\': 10},\n
packet_size=1, # Person_storeOpenOrderJournal generates big transactions\n
portal_type=\'Person\'\n
)\n
\n
context.activate(after_tag=tag).getId()\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
......
......@@ -50,9 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[
person = context\n
<value> <string>person = context\n
portal = context.getPortalObject()\n
catalog = portal.portal_catalog\n
\n
......@@ -62,8 +60,8 @@ setup_resource_uid = portal.restrictedTraverse(portal.portal_preferences.getPref
person_uid = person.getUid()\n
\n
kw = {}\n
if indexation_timestamp is not None:\n
kw[\'indexation_timestamp\'] = ">= %s" % indexation_timestamp\n
if modification_date is not None:\n
kw[\'modification_date\'] = Query(modification_date=modification_date, range="min")\n
\n
remove_hosting_list = []\n
add_kw_list = []\n
......@@ -126,13 +124,11 @@ for setup_line in catalog(\n
result = person.Person_updateOpenOrder(src__=src__, remove_hosting_list=remove_hosting_list, add_kw_list=add_kw_list, start_date_tuple_list=start_date_tuple_list, stop_date=stop_date)\n
from pprint import pformat\n
return pformat(result)\n
]]></string> </value>
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>src__=0, indexation_timestamp=None, tag=None, stop_date=None</string> </value>
<value> <string>src__=0, modification_date=None, tag=None, stop_date=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
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