allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefanoi...@apache.org
Subject git commit: [#5453] Fix computation of average stats
Date Sun, 14 Apr 2013 20:01:16 GMT
Updated Branches:
  refs/heads/master 15b4e7a25 -> 1dd8575cb


[#5453] Fix computation of average stats


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/1dd8575c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/1dd8575c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/1dd8575c

Branch: refs/heads/master
Commit: 1dd8575cbf82fe5c5237e5c0f5188ae7691cfe9f
Parents: 15b4e7a
Author: Stefano Invernizzi <stefanoinve@apache.org>
Authored: Sun Apr 14 21:58:55 2013 +0200
Committer: Stefano Invernizzi <stefanoinve@apache.org>
Committed: Sun Apr 14 21:58:55 2013 +0200

----------------------------------------------------------------------
 Allura/allura/model/stats.py |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/1dd8575c/Allura/allura/model/stats.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/stats.py b/Allura/allura/model/stats.py
index df4e45a..02c2fc4 100644
--- a/Allura/allura/model/stats.py
+++ b/Allura/allura/model/stats.py
@@ -97,7 +97,7 @@ class Stats(MappedClass):
                 tickets = val['tickets']
                 if tickets.assigned == 0:
                     return 0
-                return float(tickets.solved) / tickets.assigned
+                return round(float(tickets.solved) / tickets.assigned, 2)
         return 0
 
     @classmethod
@@ -106,8 +106,9 @@ class Stats(MappedClass):
         n = res.count()
         if n == 0:
             return 0, 0
-        maxcontribution=max([x.getCodeContribution() for x in res])
-        averagecontribution=sum([x.getCodeContribution() for x in res]) / n
+        values = [x.getCodeContribution() for x in res]
+        maxcontribution=max(values)
+        averagecontribution=sum(values) / n
         return maxcontribution, round(averagecontribution, 2)
 
     @classmethod
@@ -116,8 +117,9 @@ class Stats(MappedClass):
         n = res.count()
         if n == 0:
             return 0, 0
-        maxcontribution=max([x.getDiscussionContribution() for x in res])
-        averagecontribution=sum([x.getDiscussionContribution() for x in res])/n
+        values = [x.getDiscussionContribution() for x in res]
+        maxcontribution=max(values)
+        averagecontribution=sum(values)/n
         return maxcontribution, round(averagecontribution, 2)
 
     @classmethod
@@ -126,8 +128,9 @@ class Stats(MappedClass):
         n = res.count()
         if n == 0:
             return 0, 0
-        maxcontribution=max([x.getTicketsContribution() for x in res])
-        averagecontribution=sum([x.getTicketsContribution() for x in res])/n
+        values = [x.getTicketsContribution() for x in res]
+        maxcontribution=max(values)
+        averagecontribution=sum(values)/n
         return maxcontribution, round(averagecontribution, 2)
 
     def codeRanking(self):


Mime
View raw message