Commit b16d0c48 authored by Jérome Perrin's avatar Jérome Perrin

administration: workaround alarm.getLastActiveProcess not during alarm execution

Describe the problem as a code comment in Alarm.getLastActiveProcess for
now
parent 9b549d11
kw = {} kw = {}
if context.getProperty('incremental_check'): if context.getProperty('incremental_check'):
last_active_process = context.getLastActiveProcess() last_active_process = context.getLastActiveProcess(include_active=True)
if last_active_process is not None: if last_active_process is not None:
kw['indexation_timestamp'] = { kw['indexation_timestamp'] = {
'query': last_active_process.getStartDate(), 'query': last_active_process.getStartDate(),
......
...@@ -344,11 +344,19 @@ Alarm Tool Node: %s ...@@ -344,11 +344,19 @@ Alarm Tool Node: %s
def getLastActiveProcess(self, include_active=False): def getLastActiveProcess(self, include_active=False):
""" """
This returns the last active process finished. So it will This returns the last active process finished. So it will
not returns the current one not returns the current one. ( XXX this docstring looks wrong. What about include_active ?)
""" """
if include_active: if include_active:
limit = 1 limit = 1
else: else:
# XXX bug !
# This cannot be trusted during alarm execution.
# When alarm is running, isActive returns, then we assume that the latest
# created active process returned by the catalog is the "currently
# active" active process, but if the currently active active process is not yet indexed, we
# this method does not return the latest active process, but the previous one.
limit = self.isActive() and 2 or 1 limit = self.isActive() and 2 or 1
active_process_list = self.getPortalObject().portal_catalog( active_process_list = self.getPortalObject().portal_catalog(
portal_type='Active Process', limit=limit, portal_type='Active Process', limit=limit,
......
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