Statistiques plus jolies et complètes
This commit is contained in:
parent
cd4fe67929
commit
c716862c7d
4 changed files with 75 additions and 7 deletions
|
@ -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
|
// Recherche
|
||||||
|
|
|
@ -1206,6 +1206,25 @@ article.promo .explications > div p {
|
||||||
margin-right: 5%;
|
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 */
|
/* line 3, ../../sass/_recherche.scss */
|
||||||
section.content.recherche form.recherche .generale {
|
section.content.recherche form.recherche .generale {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
|
@ -11,10 +11,22 @@
|
||||||
<article>
|
<article>
|
||||||
<h2>Stages</h2>
|
<h2>Stages</h2>
|
||||||
<p>{{ num_stages }} stages créés, {{ num_stages_pub }} stages publiés</p>
|
<p>{{ num_stages }} stages créés, {{ num_stages_pub }} stages publiés</p>
|
||||||
<p>{% for npm in num_par_matiere %}
|
<table class="stats">
|
||||||
{{ npm.scount }} en {{ npm.matieres__nom }},
|
<tbody>
|
||||||
{% endfor %}
|
<tr><th>Matière</th><th>Fiches publiques</th><th>Brouillons</th></tr>
|
||||||
</p>
|
{% for npm in num_par_matiere %}
|
||||||
|
<tr><td>{{ npm.matiere }}</td><td>{{ npm.publics }}</td><td>{{ npm.drafts }}</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<table class="stats">
|
||||||
|
<tbody>
|
||||||
|
<tr><th>Longueur des avis</th><th>Sur le stage</th><th>Sur les lieux</th></tr>
|
||||||
|
{% for longueur, nlstages, nllieux in num_par_longueur %}
|
||||||
|
<tr><td>{{ longueur }}</td><td>{{ nlstages }}</td><td>{{ nllieux }}</td></tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
<h2>Utilisateurs</h2>
|
<h2>Utilisateurs</h2>
|
||||||
<p>{{ num_users }} utilisateurs connectés au moins une fois, {{ num_auteurs }} ont écrit une fiche</p>
|
<p>{{ num_users }} utilisateurs connectés au moins une fois, {{ num_auteurs }} ont écrit une fiche</p>
|
||||||
<p>{% for nsta, naut in num_par_auteur %}
|
<p>{% for nsta, naut in num_par_auteur %}
|
||||||
|
|
|
@ -12,7 +12,7 @@ from braces.views import LoginRequiredMixin
|
||||||
from django.http import JsonResponse, HttpResponseForbidden
|
from django.http import JsonResponse, HttpResponseForbidden
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.db.models import Q, Count
|
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.models import Normalien, Stage, Lieu, AvisLieu, AvisStage
|
||||||
from avisstage.forms import StageForm, LieuForm, AvisStageForm, AvisLieuForm, FeedbackForm
|
from avisstage.forms import StageForm, LieuForm, AvisStageForm, AvisLieuForm, FeedbackForm
|
||||||
|
@ -288,7 +288,21 @@ def feedback(request):
|
||||||
def statistiques(request):
|
def statistiques(request):
|
||||||
nstages = Stage.objects.count()
|
nstages = Stage.objects.count()
|
||||||
npubstages = Stage.objects.filter(public=True).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()
|
nusers = Normalien.objects.count()
|
||||||
nauts = Normalien.objects.filter(stages__isnull=False).distinct().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()
|
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_users': nusers,
|
||||||
'num_auteurs': nauts,
|
'num_auteurs': nauts,
|
||||||
'num_par_auteur': nbyaut,
|
'num_par_auteur': nbyaut,
|
||||||
'num_lieux_utiles': nlieux})
|
'num_lieux_utiles': nlieux,
|
||||||
|
'num_par_longueur': nbylength,
|
||||||
|
})
|
||||||
|
|
Loading…
Reference in a new issue