[damned-lies] Fix language release stats
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Fix language release stats
- Date: Mon, 8 Aug 2011 20:45:20 +0000 (UTC)
commit 7ab709b43b69f83c4c9788e8087ba6f4e7a58484
Author: Claude Paroz <claude 2xlibre net>
Date: Mon Aug 8 22:44:50 2011 +0200
Fix language release stats
stats/models.py | 9 ++++-----
stats/tests/__init__.py | 11 ++++++++++-
2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 9838d9f..16e7902 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -964,10 +964,10 @@ class Release(models.Model):
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_ui_stats])
for lang in Language.objects.all():
- total_part_ui_strings[lang.locale] = self.total_part_for_lang(lang.locale, all_ui_pots, stats_d)
+ total_part_ui_strings[lang.locale] = self.total_part_for_lang(lang, all_ui_pots, stats_d)
return total_part_ui_strings
- def total_part_for_lang(self, locale, all_pots=None, all_stats_d=None):
+ def total_part_for_lang(self, lang, all_pots=None, all_stats_d=None):
""" For partial UI stats, the total number can differ from lang to lang, so we
are bound to iterate each stats to sum it """
if all_pots is None:
@@ -980,7 +980,7 @@ class Release(models.Model):
st['part_po__translated'] + st['part_po__fuzzy'] + st['part_po__untranslated']) for st in all_stats])
total = 0
for stat in all_pots:
- key = "%d-%d-%s" % (stat.branch_id, stat.domain_id, locale)
+ key = "%d-%d-%s" % (stat.branch_id, stat.domain_id, lang.locale)
total += all_stats_d.get(key, stat.part_po.untranslated)
return total
@@ -989,7 +989,7 @@ class Release(models.Model):
language """
total_doc, total_ui = self.total_strings()
- total_ui_part = 0
+ total_ui_part = self.total_part_for_lang(lang)
query = """
SELECT domain.dtype,
SUM(pofull.translated) AS trans,
@@ -1024,7 +1024,6 @@ class Release(models.Model):
if res[0] == 'ui':
stats['uitrans'] = res[1]
stats['uifuzzy'] = res[2]
- total_ui_part = res[3] + res[4] + res[5]
stats['uitrans_part'] = res[3]
stats['uifuzzy_part'] = res[4]
if res[0] == 'doc':
diff --git a/stats/tests/__init__.py b/stats/tests/__init__.py
index abefe5d..108cbe3 100644
--- a/stats/tests/__init__.py
+++ b/stats/tests/__init__.py
@@ -27,7 +27,7 @@ from django.core.exceptions import ValidationError
from django.core.urlresolvers import reverse
from django.conf import settings
-from stats.models import Module, Domain, Branch, Category, Release, Language, Statistics, Information
+from stats.models import Module, Domain, Branch, Category, Release, Statistics, Information
from stats.utils import check_program_presence, run_shell_command
from languages.models import Language
@@ -261,3 +261,12 @@ class ModuleTestCase(TestCase):
update_doap_infos(self.mod)
self.assertEquals(self.mod.homepage, "http://git.gnome.org/browse/gnome-hello")
+
+class StatisticsTests(TestCase):
+ fixtures = ['sample_data.json']
+ 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'], total_for_lang['uitotal_part'])
+ total_for_lang = rel.total_for_lang(Language.objects.get(locale='bem'))
+ self.assertEqual(total_for_lang['uitotal'], total_for_lang['uitotal_part'])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]