diff options
Diffstat (limited to 'euscanwww/djeuscan/views.py')
-rw-r--r-- | euscanwww/djeuscan/views.py | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/euscanwww/djeuscan/views.py b/euscanwww/djeuscan/views.py index 1b128a4..b599d4c 100644 --- a/euscanwww/djeuscan/views.py +++ b/euscanwww/djeuscan/views.py @@ -380,21 +380,12 @@ def config(request): @render_to("euscan/statistics.html") def statistics(request): - # Didn't found a way to do: - # SELECT COUNT(*), AVG(confidence) FROM Versions - # GROUP BY handler - handlers = ( Version.objects.values("handler") - .filter(overlay="") - .annotate(n=models.Count("handler")) + handlers = ( + Version.objects.values("handler") + .filter(overlay="") + .annotate(n=models.Count("handler"), + avg_conf=models.Avg("confidence")) ) - for i in xrange(len(handlers)): - handler_id = handlers[i]['handler'] - avg = ( Version.objects.filter(handler=handler_id) - .aggregate(avg=models.Avg("confidence")) - ) - if not handler_id: - handlers[i]['handler'] = "None" - handlers[i]['avg_conf'] = avg['avg'] if 'avg' in avg else 0 return {"handlers": handlers} |