[damned-lies] Exclude domains, not branches when computing release/lang statistics
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Exclude domains, not branches when computing release/lang statistics
- Date: Thu, 4 Aug 2016 19:53:04 +0000 (UTC)
commit c7a4a10b009dade892e103abeed5123145e9c91d
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Aug 4 21:51:46 2016 +0200
Exclude domains, not branches when computing release/lang statistics
stats/models.py | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 804adba..ed8082b 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -929,13 +929,15 @@ class Release(models.Model):
return _(self.description)
@cached_property
- def excluded_branches(self):
- # Compute stats which doesn't apply for this release due to limited domain
+ def excluded_domains(self):
+ # Compute domains which doesn't apply for this release due to limited domain
+ # (by branch_from/branch_to).
limited_stats = Statistics.objects.select_related('branch', 'domain'
).filter(branch__releases=self
+ ).filter(language__isnull=True
).filter(models.Q(domain__branch_from__isnull=False) |
models.Q(domain__branch_to__isnull=False))
- return [st.branch for st in limited_stats if not st.branch.has_domain(st.domain)]
+ return set([st.domain for st in limited_stats if not st.branch.has_domain(st.domain)])
@classmethod
def total_by_releases(cls, dtype, releases):
@@ -954,7 +956,7 @@ class Release(models.Model):
lang_dict = dict((lang.locale, lang) for lang in Language.objects.all())
for rel in releases:
query = Statistics.objects.filter(domain__dtype=dtype, branch__releases=rel
- ).exclude(branch__in=rel.excluded_branches
+ ).exclude(domain__in=rel.excluded_domains
).values('language__locale'
).annotate(trans=models.Sum('full_po__translated'), fuzzy=models.Sum('full_po__fuzzy'),
untrans=models.Sum('full_po__untranslated')
@@ -983,7 +985,7 @@ class Release(models.Model):
""" Returns the total number of strings in the release as a tuple (doc_total, ui_total) """
# Use pot stats to compute total sum
qs = Statistics.objects.filter(branch__category__release=self, language__isnull=True
- ).exclude(branch__in=self.excluded_branches).values('domain__dtype'
+ ).exclude(domain__in=self.excluded_domains).values('domain__dtype'
).annotate(untrans=models.Sum('full_po__untranslated'))
totals = Counter()
for line in qs:
@@ -994,10 +996,10 @@ class Release(models.Model):
""" Return total partial UI strings for each language """
total_part_ui_strings = {}
all_ui_pots = Statistics.objects.select_related('part_po'
- ).exclude(branch__in=self.excluded_branches
+ ).exclude(domain__in=self.excluded_domains
).filter(language__isnull=True, branch__releases=self, domain__dtype='ui')
all_ui_stats = Statistics.objects.select_related('part_po', 'language'
- ).exclude(branch__in=self.excluded_branches
+ ).exclude(domain__in=self.excluded_domains
).filter(language__isnull=False, branch__releases=self, domain__dtype='ui'
).values('branch_id', 'domain_id', 'language__locale', 'part_po__translated', 'part_po__fuzzy',
'part_po__untranslated')
stats_d = dict([("%d-%d-%s" % (st['branch_id'], st['domain_id'], st['language__locale']),
@@ -1011,11 +1013,11 @@ class Release(models.Model):
are bound to iterate each stats to sum it """
if all_pots is None:
all_pots = Statistics.objects.select_related('part_po'
- ).exclude(branch__in=self.excluded_branches
+ ).exclude(domain__in=self.excluded_domains
).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'
- ).exclude(branch__in=self.excluded_branches
+ ).exclude(domain__in=self.excluded_domains
).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']),
@@ -1033,7 +1035,7 @@ class Release(models.Model):
total_doc, total_ui = self.total_strings()
total_ui_part = self.total_part_for_lang(lang)
query = Statistics.objects.filter(language=lang, branch__releases=self
- ).exclude(branch__in=self.excluded_branches
+ ).exclude(domain__in=self.excluded_domains
).values('domain__dtype'
).annotate(trans=models.Sum('full_po__translated'), fuzzy=models.Sum('full_po__fuzzy'),
trans_p=models.Sum('part_po__translated'), fuzzy_p=models.Sum('part_po__fuzzy'))
@@ -1079,7 +1081,7 @@ class Release(models.Model):
Returns a sorted list: (language name and locale, ui, ui-part and doc stats dictionaries) """
query = Statistics.objects.filter(language__isnull=False, branch__releases=self
- ).exclude(branch__in=self.excluded_branches
+ ).exclude(domain__in=self.excluded_domains
).values('domain__dtype', 'language'
).annotate(trans=models.Sum('full_po__translated'), fuzzy=models.Sum('full_po__fuzzy'),
trans_p=models.Sum('part_po__translated'), fuzzy_p=models.Sum('part_po__fuzzy'),
@@ -1147,7 +1149,7 @@ class Release(models.Model):
partial = False
if dtype == "ui-part":
dtype, partial = "ui", True
- pot_stats = Statistics.objects.exclude(branch__in=self.excluded_branches
+ pot_stats = Statistics.objects.exclude(domain__in=self.excluded_domains
).filter(language=None, branch__releases=self, domain__dtype=dtype, full_po__isnull=False)
po_stats = dict([("%s-%s" % (st.branch_id, st.domain_id), st)
for st in Statistics.objects.filter(language=lang, branch__releases=self,
domain__dtype=dtype)])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]