From f1ca242b2f6349adc34b84efc472eb9805afb2be Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 16 Jul 2020 14:46:37 +0200 Subject: [PATCH] adapt statistics to tracks with unset language --- nonstop/templates/nonstop/statistics.html | 4 +++- nonstop/views.py | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/nonstop/templates/nonstop/statistics.html b/nonstop/templates/nonstop/statistics.html index 6bffc6e..a1cb9b2 100644 --- a/nonstop/templates/nonstop/statistics.html +++ b/nonstop/templates/nonstop/statistics.html @@ -30,9 +30,11 @@
  • CFWB: {{zone.stats.cfwb}} ({{zone.stats.cfwb_percentage}}) {% if zone.stats.quota_cfwb %}✅{% else %}❌{% endif %}
  • -
  • French-speaking: {{zone.stats.french}} ({{zone.stats.french_percentage}}, % hors instrus) +
  • French-speaking: {{zone.stats.french}} ({{zone.stats.french_percentage}}, + % hors instrus et où la langue est connue) {% if zone.stats.quota_french %}✅{% else %}❌{% endif %}
  • +
  • {% trans "Unset language:" %} {{zone.stats.unset_language}} ({{zone.stats.unset_language_percentage}})
  • diff --git a/nonstop/views.py b/nonstop/views.py index 18a909d..f0eee55 100644 --- a/nonstop/views.py +++ b/nonstop/views.py @@ -151,11 +151,20 @@ class ZoneStats(object): def cfwb_percentage(self): return self.percentage(cfwb=True) + def unset_language(self): + return self.count(language='') + + def unset_language_percentage(self): + return self.percentage(language='') + def french(self): return self.count(language='fr') + def unset_or_na_language(self): + return self.qs.filter(Q(language='') | Q(language='na')).count() + def french_percentage(self): - considered_tracks = self.count() - self.instru() + considered_tracks = self.count() - self.unset_or_na_language() if considered_tracks == 0: return '-' return '%.2f%%' % (100. * self.french() / considered_tracks) @@ -163,7 +172,7 @@ class ZoneStats(object): def quota_french(self): # obligation de diffuser annuellement au moins 30% d'œuvres musicales de # langue française - considered_tracks = self.count() - self.instru() + considered_tracks = self.count() - self.unset_or_na_language() if considered_tracks == 0: return True return (100. * self.french() / considered_tracks) > 30. -- 2.39.2