[damned-lies] Fix language stats total number



commit 5390a3445f6528bc3b834d21cfc5992a7d3be4d4
Author: Claude Paroz <claude 2xlibre net>
Date:   Fri Aug 12 19:32:46 2011 +0200

    Fix language stats total number

 stats/models.py         |    2 +-
 stats/tests/__init__.py |    5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 4c8ceef..1b9f1a6 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -974,7 +974,7 @@ class Release(models.Model):
             all_pots = Statistics.objects.select_related('part_po').filter(language__isnull=True, branch__releases=self, domain__dtype='ui')
         if all_stats_d is None:
             all_stats = Statistics.objects.select_related('part_po', 'language'
-                ).filter(language__locale=lang, branch__releases=self, domain__dtype='ui'
+                ).filter(language=lang, branch__releases=self, domain__dtype='ui'
                 ).values('branch_id', 'domain_id', 'language__locale', 'part_po__translated', 'part_po__fuzzy', 'part_po__untranslated')
             all_stats_d = dict([("%d-%d-%s" % (st['branch_id'], st['domain_id'], st['language__locale']),
                                 st['part_po__translated'] + st['part_po__fuzzy'] + st['part_po__untranslated']) for st in all_stats])
diff --git a/stats/tests/__init__.py b/stats/tests/__init__.py
index a61eb88..82cdfe7 100644
--- a/stats/tests/__init__.py
+++ b/stats/tests/__init__.py
@@ -267,9 +267,12 @@ class StatisticsTests(TestCase):
     def testTotalStatsForLang(self):
         rel  = Release.objects.get(name="gnome-2-30")
         total_for_lang = rel.total_for_lang(Language.objects.get(locale='fr'))
-        self.assertEqual(total_for_lang['uitotal']-8, total_for_lang['uitotal_part'])
+        self.assertEqual(total_for_lang['uitotal'], total_for_lang['uitotal_part'])
+        self.assertTrue(total_for_lang['uiuntrans'] == total_for_lang['uiuntrans_part'] == 0)
         total_for_lang = rel.total_for_lang(Language.objects.get(locale='bem'))
         self.assertEqual(total_for_lang['uitotal']-8, total_for_lang['uitotal_part'])
+        self.assertEqual(total_for_lang['uiuntrans'], 183)
+        self.assertEqual(total_for_lang['uiuntrans_part'], 175)
 
     def testStatsLinks(self):
         pot_stats = Statistics.objects.get(



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