[damned-lies] Avoid null values in total_for_lang method
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Avoid null values in total_for_lang method
- Date: Sun, 21 Mar 2021 18:15:15 +0000 (UTC)
commit f0d5dec264a74a79e8ce93676e77978b9003e318
Author: Claude Paroz <claude 2xlibre net>
Date: Sun Mar 21 15:26:57 2021 +0100
Avoid null values in total_for_lang method
stats/models.py | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/stats/models.py b/stats/models.py
index bdcde8c1..29eb845f 100644
--- a/stats/models.py
+++ b/stats/models.py
@@ -1052,8 +1052,12 @@ class Release(models.Model):
query = Statistics.objects.filter(language=lang, branch__releases=self
).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'))
+ ).annotate(
+ trans=Coalesce(models.Sum('full_po__translated'), models.Value(0)),
+ fuzzy=Coalesce(models.Sum('full_po__fuzzy'), models.Value(0)),
+ trans_p=Coalesce(models.Sum('part_po__translated'), models.Value(0)),
+ fuzzy_p=Coalesce(models.Sum('part_po__fuzzy'), models.Value(0))
+ )
stats = {'id': self.id, 'name': self.name, 'description': _(self.description),
'ui': {'translated': 0, 'fuzzy': 0, 'total': total_ui,
'translated_perc': 0, 'fuzzy_perc': 0, 'untranslated_perc': 0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]