From c7672a5500f7549eb542080f6f0ea2abad96f9d6 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 14 Apr 2016 20:26:50 +0200 Subject: [PATCH] compute delays to first arrival of each formdata in each status (#10669) Currently we only account for formdata currently in the status for which we are measuring delays, it makes it impossible to accurately measure delays in the past. --- wcs/backoffice/management.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/wcs/backoffice/management.py b/wcs/backoffice/management.py index 2e082aa..3d4198a 100644 --- a/wcs/backoffice/management.py +++ b/wcs/backoffice/management.py @@ -1604,7 +1604,7 @@ class FormPage(Directory): return r.getvalue() def stats_resolution_time(self, values): - possible_status = [('wf-%s' % x.id, x.id) for x in self.formdef.workflow.possible_status] + possible_status = [('wf-%s' % x.id, x.id) for x in self.formdef.workflow.possible_status[1:]] if len(possible_status) < 2: return @@ -1613,20 +1613,28 @@ class FormPage(Directory): r += htmltext('

%s

') % _('Resolution time') for status, status_id in possible_status: - res_time_forms = [ - (time.mktime(x.evolution[-1].time) - time.mktime(x.receipt_time)) \ - for x in values if x.status == status and x.evolution] + def collect_res_time_forms(): + for filled in values: + for evo in filled.evolution or []: + if evo.status == 'wf-%s' % status_id: + yield time.mktime(evo.time) - time.mktime(filled.receipt_time) + break + + res_time_forms = list(collect_res_time_forms()) if not res_time_forms: continue res_time_forms.sort() sum_times = sum(res_time_forms) len_times = len(res_time_forms) + min_times = res_time_forms[0] + max_times = res_time_forms[-1] r += htmltext('

%s

') % (_('To Status "%s"') % self.formdef.workflow.get_status(status_id).name) r += htmltext('