[damned-lies] Fixed race condition issue with empty part fields of stats



commit 99942846b8ea5cef500c99a8b2a6ae5a2dbc9b48
Author: Claude Paroz <claude 2xlibre net>
Date:   Wed Jan 24 13:43:34 2018 +0100

    Fixed race condition issue with empty part fields of stats

 stats/models.py |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index 7af627e..ef756ce 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1028,8 +1028,11 @@ class Release(models.Model):
             ).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']),
-                        st['part_po__translated'] + st['part_po__fuzzy'] + st['part_po__untranslated']) for 
st in all_ui_stats])
+        stats_d = {
+            "%d-%d-%s" % (st['branch_id'], st['domain_id'], st['language__locale']
+            ): (st['part_po__translated'] or 0) + (st['part_po__fuzzy'] or 0) + (st['part_po__untranslated'] 
or 0)
+            for st in all_ui_stats
+        }
         for lang in Language.objects.all():
             total_part_ui_strings[lang.locale] = self.total_part_for_lang(lang, all_ui_pots, stats_d)
         return total_part_ui_strings


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