[damned-lies] Guard against None value in stats sum
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Guard against None value in stats sum
- Date: Thu, 8 Nov 2018 07:45:37 +0000 (UTC)
commit 8ffd354271b97be0265c2a7e6bf02091a7b53d29
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Nov 8 08:44:53 2018 +0100
Guard against None value in stats sum
stats/models.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index ae90b4cc..f1b8f00e 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1011,8 +1011,11 @@ class Release(models.Model):
).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']),
- st['part_po__translated'] + st['part_po__fuzzy'] +
st['part_po__untranslated']) for st in all_stats])
+ all_stats_d = {
+ "%d-%d-%s" % (st['branch_id'], st['domain_id'], st['language__locale']): sum(filter(
+ None, [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, lang.locale)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]