From c716862c7d5db162766774d95bf96504dc8caf37 Mon Sep 17 00:00:00 2001 From: Evarin Date: Sun, 9 Sep 2018 00:17:11 +0200 Subject: [PATCH] =?UTF-8?q?Statistiques=20plus=20jolies=20et=20compl=C3=A8?= =?UTF-8?q?tes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- avisstage/sass/screen.scss | 21 ++++++++++++++++++ avisstage/static/css/screen.css | 19 ++++++++++++++++ .../avisstage/moderation/statistiques.html | 20 +++++++++++++---- avisstage/views.py | 22 ++++++++++++++++--- 4 files changed, 75 insertions(+), 7 deletions(-) diff --git a/avisstage/sass/screen.scss b/avisstage/sass/screen.scss index ceee16a..bd13125 100644 --- a/avisstage/sass/screen.scss +++ b/avisstage/sass/screen.scss @@ -857,6 +857,27 @@ article.promo { } } +// +// +// Modération + +table.stats { + width: 100%; + background: #fff; + margin: 20px 0; + cellspacing: 1px; + th { + font-weight: bold; + border-top: 1px solid #000; + border-bottom: 1px solid #999; + } + td, th { + padding: 5px 3px; + text-align: center; + } +} + + // // // Recherche diff --git a/avisstage/static/css/screen.css b/avisstage/static/css/screen.css index 496a799..188b13b 100644 --- a/avisstage/static/css/screen.css +++ b/avisstage/static/css/screen.css @@ -1206,6 +1206,25 @@ article.promo .explications > div p { margin-right: 5%; } +/* line 864, ../../sass/screen.scss */ +table.stats { + width: 100%; + background: #fff; + margin: 20px 0; + cellspacing: 1px; +} +/* line 869, ../../sass/screen.scss */ +table.stats th { + font-weight: bold; + border-top: 1px solid #000; + border-bottom: 1px solid #999; +} +/* line 874, ../../sass/screen.scss */ +table.stats td, table.stats th { + padding: 5px 3px; + text-align: center; +} + /* line 3, ../../sass/_recherche.scss */ section.content.recherche form.recherche .generale { display: inline-block; diff --git a/avisstage/templates/avisstage/moderation/statistiques.html b/avisstage/templates/avisstage/moderation/statistiques.html index 5925c6b..2f2c9b5 100644 --- a/avisstage/templates/avisstage/moderation/statistiques.html +++ b/avisstage/templates/avisstage/moderation/statistiques.html @@ -11,10 +11,22 @@

Stages

{{ num_stages }} stages créés, {{ num_stages_pub }} stages publiés

-

{% for npm in num_par_matiere %} - {{ npm.scount }} en {{ npm.matieres__nom }}, - {% endfor %} -

+ + + + {% for npm in num_par_matiere %} + + {% endfor %} + +
MatièreFiches publiquesBrouillons
{{ npm.matiere }}{{ npm.publics }}{{ npm.drafts }}
+ + + + {% for longueur, nlstages, nllieux in num_par_longueur %} + + {% endfor %} + +
Longueur des avisSur le stageSur les lieux
{{ longueur }}{{ nlstages }}{{ nllieux }}

Utilisateurs

{{ num_users }} utilisateurs connectés au moins une fois, {{ num_auteurs }} ont écrit une fiche

{% for nsta, naut in num_par_auteur %} diff --git a/avisstage/views.py b/avisstage/views.py index a59bce5..23ef4e4 100644 --- a/avisstage/views.py +++ b/avisstage/views.py @@ -12,7 +12,7 @@ from braces.views import LoginRequiredMixin from django.http import JsonResponse, HttpResponseForbidden from django.core.mail import send_mail from django.db.models import Q, Count -from collections import Counter +from collections import Counter, defaultdict from avisstage.models import Normalien, Stage, Lieu, AvisLieu, AvisStage from avisstage.forms import StageForm, LieuForm, AvisStageForm, AvisLieuForm, FeedbackForm @@ -288,7 +288,21 @@ def feedback(request): def statistiques(request): nstages = Stage.objects.count() npubstages = Stage.objects.filter(public=True).count() - nbymatiere = Stage.objects.values('matieres__nom').annotate(scount=Count('matieres__nom')) + nbymatiere_raw = Stage.objects.values('matieres__nom', 'public').annotate(scount=Count('matieres__nom')) + nbymatiere = defaultdict(dict) + for npm in nbymatiere_raw: + nbymatiere[npm["matieres__nom"]]["publics" if npm["public"] else "drafts"] = npm["scount"] + for mat, npm in nbymatiere.items(): + npm["matiere"] = mat + nbymatiere = sorted(list(nbymatiere.values()), key=lambda npm: npm["publics"]) + nbylength = [("Vide", Stage.objects.filter(len_avis_stage__lt=5).count(), + Stage.objects.filter(len_avis_lieux__lt=5).count()), + ("Court", Stage.objects.filter(len_avis_stage__lt=30, len_avis_stage__gt=4).count(), + Stage.objects.filter(len_avis_lieux__lt=30, len_avis_lieux__gt=4).count()), + ("Moyen", Stage.objects.filter(len_avis_stage__lt=100, len_avis_stage__gt=29).count(), + Stage.objects.filter(len_avis_lieux__lt=100, len_avis_lieux__gt=29).count()), + ("Long", Stage.objects.filter(len_avis_stage__gt=99).count(), + Stage.objects.filter(len_avis_lieux__gt=99).count())] nusers = Normalien.objects.count() nauts = Normalien.objects.filter(stages__isnull=False).distinct().count() nbyaut = Counter(Normalien.objects.filter(stages__isnull=False).annotate(scount=Count('stages')).values_list('scount', flat="True")).items() @@ -300,4 +314,6 @@ def statistiques(request): 'num_users': nusers, 'num_auteurs': nauts, 'num_par_auteur': nbyaut, - 'num_lieux_utiles': nlieux}) + 'num_lieux_utiles': nlieux, + 'num_par_longueur': nbylength, + })