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 |
res_time_forms = []
|
|
1617 |
for filled in values:
|
|
1618 |
for evo in filled.evolution or []:
|
|
1619 |
if evo.status == 'wf-%s' % status_id:
|
|
1620 |
res_time_forms.append(time.mktime(evo.time)
|
|
1621 |
- time.mktime(filled.receipt_time))
|
|
1622 |
break
|
1619 |
1623 |
if not res_time_forms:
|
1620 |
1624 |
continue
|
1621 |
1625 |
res_time_forms.sort()
|
1622 |
1626 |
sum_times = sum(res_time_forms)
|
1623 |
1627 |
len_times = len(res_time_forms)
|
|
1628 |
min_times = res_time_forms[0]
|
|
1629 |
max_times = res_time_forms[-1]
|
1624 |
1630 |
r += htmltext('<h3>%s</h3>') % (_('To Status "%s"') % self.formdef.workflow.get_status(status_id).name)
|
1625 |
1631 |
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
|
|
1632 |
r += htmltext(' <li>%s %s</li>') % (_('Count:'), len_times)
|
|
1633 |
r += htmltext(' <li>%s %s</li>') % (_('Minimum Time:'), format_time(min_times))
|
|
1634 |
r += htmltext(' <li>%s %s</li>') % (_('Maximum Time:'), format_time(max_times))
|
|
1635 |
r += htmltext(' <li>%s %s</li>') % (_('Range:'), format_time(max_times - min_times))
|
|
1636 |
mean = sum_times / len_times
|
1630 |
1637 |
r += htmltext(' <li>%s %s</li>') % (_('Mean:'), format_time(mean))
|
1631 |
1638 |
if len_times % 2:
|
1632 |
1639 |
median = res_time_forms[len_times/2]
|
1633 |
|
-
|