Affichage de statistiques sur la page d'import
This commit is contained in:
parent
5dffc1f0b2
commit
df18e9d88f
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ from django.core.files.storage import default_storage
|
||||
from django.core.mail import send_mail
|
||||
from django.db import connection, models
|
||||
from django.db.models import Count, F, Func, OuterRef, Q, Subquery
|
||||
from django.db.models.functions import Lower
|
||||
from django.db.models.functions import Lower, ExtractDay
|
||||
from django.template.defaultfilters import date as _date
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.template.loader import render_to_string
|
||||
@ -2728,6 +2728,27 @@ class RecurrentImport(models.Model):
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_foresight_quality(self):
|
||||
from statistics import median, mean, stdev
|
||||
|
||||
values = [
|
||||
x["foresight"]
|
||||
for x in Event.objects.filter(import_sources__contains=[self.source])
|
||||
.annotate(foresight=ExtractDay(F("start_day") - F("created_date")))
|
||||
.values("foresight")
|
||||
]
|
||||
if len(values) == 0:
|
||||
return []
|
||||
result = [
|
||||
[_("minimum"), min(values)],
|
||||
[_("maximum"), max(values)],
|
||||
[_("mean"), round(mean(values), 2)],
|
||||
[_("median"), median(values)],
|
||||
]
|
||||
if len(values) > 2:
|
||||
result.append([_("standard deviation"), round(stdev(values), 2)])
|
||||
return result
|
||||
|
||||
|
||||
class BatchImportation(models.Model):
|
||||
class STATUS(models.TextChoices):
|
||||
|
@ -5,9 +5,11 @@
|
||||
{% load cat_extra %}
|
||||
{% load i18n %}
|
||||
{% load utils_extra %}
|
||||
{% load static %}
|
||||
{% load tag_extra %}
|
||||
{% block entete_header %}
|
||||
{% css_categories %}
|
||||
<script src="{% static 'js/d3.v7.min.js' %}"></script>
|
||||
{% endblock %}
|
||||
{% block sidemenu-bouton %}
|
||||
<li>
|
||||
@ -83,6 +85,28 @@
|
||||
</li>
|
||||
</ul>
|
||||
</header>
|
||||
{% with object.get_foresight_quality as stat %}
|
||||
{% if stat|length > 0 %}
|
||||
<h2>Qualité de l'anticipation</h2>
|
||||
<p>
|
||||
On s'intéresse à la différence entre la date de publication d'un événement et la date effective de l'événement. Plus le nombre de jours qui les sépare est élevé, plus
|
||||
la source anticipe ses événements, et peut être considérée comme une source fiable.
|
||||
</p>
|
||||
<table>
|
||||
<thead>
|
||||
<th class="label"></th>
|
||||
{% for v in stat %}<th>{{ v.0 }}</th>{% endfor %}
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="label">Nb jours</th>
|
||||
{% for v in stat %}<th>{{ v.1 }}</th>{% endfor %}
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
<h2>Liste des imports</h2>
|
||||
{% include "agenda_culturel/batch-imports-inc.html" with objects=paginator_filter %}
|
||||
<footer>
|
||||
<span>{% include "agenda_culturel/paginator.html" %}</span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user