[damned-lies] Use Counter for total_strings()



commit 5a8ec3296c9222fa606bc5add8c58fd497a3634d
Author: Claude Paroz <claude 2xlibre net>
Date:   Tue Sep 30 08:48:39 2014 +0200

    Use Counter for total_strings()

 stats/models.py |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 7cb110d..f66ce4d 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -18,6 +18,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+from collections import Counter
 import logging
 import os, sys, re
 import threading
@@ -913,13 +914,10 @@ class Release(models.Model):
             cursor.execute("SET sql_mode='ANSI_QUOTES'")
         cursor.execute(query, (self.id,))
 
-        total_doc, total_ui = 0, 0
+        totals = Counter()
         for row in cursor.fetchall():
-            if row[0] == 'ui':
-                total_ui = row[1]
-            elif row[0] == 'doc':
-                total_doc = row[1]
-        return (total_doc, total_ui)
+            totals[row[0]] += row[1]
+        return totals['doc'], totals['ui']
 
     def total_part_for_all_langs(self):
         """ Return total partial UI strings for each language """


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]