affichage fraicheur des données

This commit is contained in:
Tykayn 2025-06-19 12:49:30 +02:00 committed by tykayn
parent 43139d50d9
commit ca00f8c0be
4 changed files with 290 additions and 5 deletions

View file

@ -19,6 +19,28 @@
.completion-info {
margin-bottom: 2rem;
}
.osm-modification-info {
font-size: 0.85rem;
line-height: 1.3;
}
.osm-modification-info .text-muted {
font-size: 0.75rem;
}
.osm-modification-info a {
text-decoration: none;
color: #0d6efd;
}
.osm-modification-info a:hover {
text-decoration: underline;
}
.osm-freshness-info {
font-size: 0.95rem;
line-height: 1.4;
}
.osm-freshness-info .alert {
border-left: 4px solid #0dcaf0;
background-color: #f8f9fa;
}
</style>
{% endblock %}
@ -59,6 +81,74 @@
</div>
</div>
{% endif %}
{# Affichage de la fraîcheur des données OSM #}
{% if stats.osmDataDateMin and stats.osmDataDateMax and stats.osmDataDateAvg %}
{% set now = "now"|date("U") %}
{% set minDate = stats.osmDataDateMin|date("U") %}
{% set maxDate = stats.osmDataDateMax|date("U") %}
{% set avgDate = stats.osmDataDateAvg|date("U") %}
{% set minDiff = now - minDate %}
{% set maxDiff = now - maxDate %}
{% set avgDiff = now - avgDate %}
{% set minYears = (minDiff / 31536000)|round(0, 'floor') %}
{% set minMonths = ((minDiff % 31536000) / 2592000)|round(0, 'floor') %}
{% set maxYears = (maxDiff / 31536000)|round(0, 'floor') %}
{% set maxMonths = ((maxDiff % 31536000) / 2592000)|round(0, 'floor') %}
{% set avgYears = (avgDiff / 31536000)|round(0, 'floor') %}
{% set avgMonths = ((avgDiff % 31536000) / 2592000)|round(0, 'floor') %}
<div class="row mb-3">
<div class="col-12">
<div class="alert alert-info osm-freshness-info">
<i class="bi bi-clock-history"></i>
<strong>Fraîcheur des données OSM :</strong>
{% if minYears == maxYears and minMonths == maxMonths %}
Toutes les modifications ont été faites il y a
{% if minYears > 0 %}
{{ minYears }} an{{ minYears > 1 ? 's' : '' }}
{% if minMonths > 0 %}, {{ minMonths }} mois{% endif %}
{% elseif minMonths > 0 %}
{{ minMonths }} mois
{% else %}
moins d'un mois
{% endif %}
{% else %}
Les modifications ont été faites entre il y a
{% if maxYears > 0 %}
{{ maxYears }} an{{ maxYears > 1 ? 's' : '' }}
{% if maxMonths > 0 %}, {{ maxMonths }} mois{% endif %}
{% elseif maxMonths > 0 %}
{{ maxMonths }} mois
{% else %}
moins d'un mois
{% endif %}
et il y a
{% if minYears > 0 %}
{{ minYears }} an{{ minYears > 1 ? 's' : '' }}
{% if minMonths > 0 %}, {{ minMonths }} mois{% endif %}
{% elseif minMonths > 0 %}
{{ minMonths }} mois
{% else %}
moins d'un mois
{% endif %},
en moyenne il y a
{% if avgYears > 0 %}
{{ avgYears }} an{{ avgYears > 1 ? 's' : '' }}
{% if avgMonths > 0 %}, {{ avgMonths }} mois{% endif %}
{% elseif avgMonths > 0 %}
{{ avgMonths }} mois
{% else %}
moins d'un mois
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endif %}
<div class="row">
<div class="col-md-3 col-12">
<span class="badge {% if stats.getCompletionPercent() > 85 %}bg-success{% else %}bg-warning{% endif %}">
@ -954,8 +1044,8 @@ window.updateMarkers = updateMarkers;
{# markClosedSiretsOnTable(); #}
function makeDonutGraphOfTags() {
// Récupérer tous les tags de la colonne 2
const tags = Array.from(document.querySelectorAll('table tbody tr td:nth-child(3)'))
// Récupérer tous les tags de la colonne 4 (Type)
const tags = Array.from(document.querySelectorAll('table tbody tr td:nth-child(4)'))
.map(cell => cell.textContent.trim())
.filter(tag => tag.includes('=')) // Filtrer les cellules qui ne contiennent pas de =
.filter(tag => tag); // Filtrer les cellules vides