Commit e681ea49 authored by Vincent Pelletier's avatar Vincent Pelletier

Avoid scanning the whole list of active processes related to an alarm when we...

Avoid scanning the whole list of active processes related to an alarm when we just want the most recent one.
When alarm is currently runing, skip latest active result to display the previous one: this way, we display the result of a complete run. This is more consistent for alarms checking big quantities of documents in multiple activities and only displaying an error when one is actualy encountered (an error at the end of a processing batch would be hidden when the next batch starts processing).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22456 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b0d76b1c
...@@ -331,6 +331,7 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -331,6 +331,7 @@ class Alarm(XMLObject, PeriodicityMixin):
The process parameter can be used to retrive sense values for The process parameter can be used to retrive sense values for
past processes. past processes.
If it is None, it will return the status of last completed active result.
""" """
method_id = self.getSenseMethodId() method_id = self.getSenseMethodId()
if process is None: if process is None:
...@@ -479,16 +480,16 @@ Alarm URL: %s ...@@ -479,16 +480,16 @@ Alarm URL: %s
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
""" """
active_process_list = self.getCausalityRelatedValueList( limit = self.isActive() and 2 or 1
portal_type='Active Process') active_process_list = self.getPortalObject().portal_catalog(
portal_type='Active Process', limit=limit,
def sort_date(a, b): sort_on=(('creation_date', 'DESC'), ),
return cmp(a.getStartDate(), b.getStartDate()) causality_uid=self.getUid())
if len(active_process_list) < limit:
active_process_list.sort(sort_date) process = None
if len(active_process_list) > 0: else:
return active_process_list[-1] process = active_process_list[-1].getObject()
return None return process
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'newActiveProcess') 'newActiveProcess')
......
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