--- /dev/null
+{% load l10n %}{% localize off %}
+{% if view.kwargs.config %}
+multigraph nonstop_general
+graph_title Nonstop Tracks
+graph_category Nonstop
+nonstop_general_total.label Total
+nonstop_general_active.label Active
+
+multigraph nonstop_percentages
+graph_title Nonstop Tracks Percentages
+graph_category Nonstop
+graph_args --upper-limit 100 -l 0
+graph_vlabel %
+graph_scale no
+nonstop_percentages_instru.label (%instru)
+nonstop_percentages_cfwb.label (%cfwb)
+nonstop_percentages_french.label (%french)
+nonstop_percentages_langset.label (%language set)
+
+{% for zone in zones %}
+multigraph nonstop_{{zone.slug|cut:"-"}}
+graph_title Nonstop Tracks ({{zone.title|safe}})
+graph_category Nonstop
+nonstop_{{zone.slug|cut:"-"}}_total.label (total)
+nonstop_{{zone.slug|cut:"-"}}_instru.label (instru)
+nonstop_{{zone.slug|cut:"-"}}_cfwb.label (cfwb)
+nonstop_{{zone.slug|cut:"-"}}_french.label (french)
+nonstop_{{zone.slug|cut:"-"}}_langset.label (language set)
+{% endfor %}
+
+{% else %}{# actual stats #}
+
+multigraph nonstop_general
+nonstop_general_total.value {{nonstop_general_total}}
+nonstop_general_active.value {{nonstop_general_active}}
+
+multigraph nonstop_percentages
+nonstop_percentages_instru.value {{nonstop_percentages_instru}}
+nonstop_percentages_cfwb.value {{nonstop_percentages_cfwb}}
+nonstop_percentages_french.value {{nonstop_percentages_french}}
+nonstop_percentages_langset.value {{nonstop_percentages_langset}}
+
+{% for zone in zones %}
+multigraph nonstop_{{zone.slug|cut:"-"}}
+nonstop_{{zone.slug|cut:"-"}}_total.value {{zone.stats.count}}
+nonstop_{{zone.slug|cut:"-"}}_instru.value {{zone.stats.instru}}
+nonstop_{{zone.slug|cut:"-"}}_cfwb.value {{zone.stats.cfwb}}
+nonstop_{{zone.slug|cut:"-"}}_french.value {{zone.stats.french}}
+nonstop_{{zone.slug|cut:"-"}}_langset.value {{zone.stats.language_set}}
+{% endfor %}
+
+{% endif %}
+{% endlocalize %}
QuickLinksView, SearchView, CleanupView, ArtistTracksMetadataView,
SearchCsvView, AddSomaDiffusionView, DelSomaDiffusionView,
DiffusionPropertiesView, AjaxProgram, ZoneSettings,
- jingle_audio_view)
+ jingle_audio_view,
+ MuninTracks)
urlpatterns = [
url(r'^$', QuickLinksView.as_view(), name='nonstop-quick-links'),
# ajax parts
url(r'^ajax/program/(?P<date>[\d-]*)$', AjaxProgram.as_view(), name='nonstop-ajax-program'),
]
+
+public_urlpatterns = [
+ url(r'^api/munin/tracks/(?P<config>config/)?$', MuninTracks.as_view()),
+]
def cfwb_percentage(self):
return self.percentage(cfwb=True)
- def unset_language(self):
+ def language_set(self):
+ return self.count() - self.language_unset()
+
+ def language_unset(self):
return self.count(language='')
def unset_language_percentage(self):
return datetime.datetime.today() + datetime.timedelta(int(date.rstrip('d')))
return datetime.datetime.strptime(date, '%Y-%m-%d').date()
+
class StatisticsView(TemplateView):
template_name = 'nonstop/statistics.html'
zone.save()
zone_settings.save()
return super().form_valid(form)
+
+
+class MuninTracks(StatisticsView):
+ template_name = 'nonstop/munin_tracks.txt'
+ content_type = 'text/plain; charset=utf-8'
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ context['nonstop_general_total'] = Track.objects.count()
+ active_tracks_qs = Track.objects.filter(nonstop_zones__isnull=False).distinct()
+ context['nonstop_general_active'] = active_tracks_qs.count()
+ context['nonstop_percentages_instru'] = 100 * (
+ active_tracks_qs.filter(instru=True).count() /
+ context['nonstop_general_active'])
+ context['nonstop_percentages_cfwb'] = 100 * (
+ active_tracks_qs.filter(cfwb=True).count() /
+ context['nonstop_general_active'])
+ context['nonstop_percentages_langset'] = 100 * (
+ active_tracks_qs.exclude(language='').count() /
+ context['nonstop_general_active'])
+ context['nonstop_percentages_french'] = 100 * (
+ active_tracks_qs.filter(language='fr').count() /
+ active_tracks_qs.exclude(language__isnull=True).exclude(language__in=('', 'na')).count())
+ return context