Projet

Général

Profil

0001-compute-delays-to-first-arrival-of-each-formdata-in-.patch

Benjamin Dauvergne, 15 avril 2016 15:49

Télécharger (3,13 ko)

Voir les différences:

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(-)
wcs/backoffice/management.py
1604 1604
        return r.getvalue()
1605 1605

  
1606 1606
    def stats_resolution_time(self, values):
1607
        possible_status = [('wf-%s' % x.id, x.id) for x in self.formdef.workflow.possible_status]
1607
        possible_status = [('wf-%s' % x.id, x.id) for x in self.formdef.workflow.possible_status[1:]]
1608 1608

  
1609 1609
        if len(possible_status) < 2:
1610 1610
            return
......
1613 1613
        r += htmltext('<h2>%s</h2>') % _('Resolution time')
1614 1614

  
1615 1615
        for status, status_id in possible_status:
1616
            res_time_forms = [
1617
                    (time.mktime(x.evolution[-1].time) - time.mktime(x.receipt_time)) \
1618
                    for x in values if x.status == status and x.evolution]
1616
            def collect_res_time_forms():
1617
                for filled in values:
1618
                    for evo in filled.evolution or []:
1619
                        if evo.status == 'wf-%s' % status_id:
1620
                            yield time.mktime(evo.time) - time.mktime(filled.receipt_time)
1621
                            break
1622

  
1623
            res_time_forms = list(collect_res_time_forms())
1619 1624
            if not res_time_forms:
1620 1625
                continue
1621 1626
            res_time_forms.sort()
1622 1627
            sum_times = sum(res_time_forms)
1623 1628
            len_times = len(res_time_forms)
1629
            min_times = res_time_forms[0]
1630
            max_times = res_time_forms[-1]
1624 1631
            r += htmltext('<h3>%s</h3>') % (_('To Status "%s"') % self.formdef.workflow.get_status(status_id).name)
1625 1632
            r += htmltext('<ul>')
1626
            r += htmltext(' <li>%s %s</li>') % (_('Minimum Time:'), format_time(min(res_time_forms)))
1627
            r += htmltext(' <li>%s %s</li>') % (_('Maximum Time:'), format_time(max(res_time_forms)))
1628
            r += htmltext(' <li>%s %s</li>') % (_('Range:'), format_time(max(res_time_forms)-min(res_time_forms)))
1629
            mean = sum_times/len_times
1633
            r += htmltext(' <li>%s %s</li>') % (_('Count:'), len_times)
1634
            r += htmltext(' <li>%s %s</li>') % (_('Minimum Time:'), format_time(min_times))
1635
            r += htmltext(' <li>%s %s</li>') % (_('Maximum Time:'), format_time(max_times))
1636
            r += htmltext(' <li>%s %s</li>') % (_('Range:'), format_time(max_times - min_times))
1637
            mean = sum_times / len_times
1630 1638
            r += htmltext(' <li>%s %s</li>') % (_('Mean:'), format_time(mean))
1631 1639
            if len_times % 2:
1632 1640
                median = res_time_forms[len_times/2]
1633
-