harmoniser les décomptes de completion sur la page stats
This commit is contained in:
parent
b9f57e48b5
commit
060b23f87e
3 changed files with 399 additions and 345 deletions
|
@ -303,11 +303,11 @@ final class AdminController extends AbstractController
|
||||||
return $this->redirectToRoute('app_admin_import_stats');
|
return $this->redirectToRoute('app_admin_import_stats');
|
||||||
}
|
}
|
||||||
|
|
||||||
$completion = $stats->getCompletionPercent();
|
// $completion = $stats->getCompletionPercent();
|
||||||
if (!$completion) {
|
// if (!$completion) {
|
||||||
$stats->computeCompletionPercent();
|
// $stats->computeCompletionPercent();
|
||||||
$completion = $stats->getCompletionPercent();
|
// $completion = $stats->getCompletionPercent();
|
||||||
}
|
// }
|
||||||
$followups = $stats->getCityFollowUps();
|
$followups = $stats->getCityFollowUps();
|
||||||
$refresh = false;
|
$refresh = false;
|
||||||
if (!$followups->isEmpty()) {
|
if (!$followups->isEmpty()) {
|
||||||
|
@ -378,7 +378,7 @@ final class AdminController extends AbstractController
|
||||||
|
|
||||||
// Update the places_count property
|
// Update the places_count property
|
||||||
$stats->setPlacesCount($stats->getPlaces()->count());
|
$stats->setPlacesCount($stats->getPlaces()->count());
|
||||||
$this->entityManager->persist($stats);
|
// $this->entityManager->persist($stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
@ -433,6 +433,15 @@ final class AdminController extends AbstractController
|
||||||
if (isset($commerces) && is_iterable($commerces)) {
|
if (isset($commerces) && is_iterable($commerces)) {
|
||||||
foreach ($commerces as $commerce) {
|
foreach ($commerces as $commerce) {
|
||||||
if ($commerce->getLat() && $commerce->getLon()) {
|
if ($commerce->getLat() && $commerce->getLon()) {
|
||||||
|
// Collect missing tags
|
||||||
|
$missingTags = [];
|
||||||
|
if (!$commerce->getName()) $missingTags[] = 'name';
|
||||||
|
if (!$commerce->hasAddress()) $missingTags[] = 'address';
|
||||||
|
if (!$commerce->hasOpeningHours()) $missingTags[] = 'opening_hours';
|
||||||
|
if (!$commerce->hasWebsite()) $missingTags[] = 'website';
|
||||||
|
if (!$commerce->hasWheelchair()) $missingTags[] = 'wheelchair';
|
||||||
|
if (!$commerce->getSiret()) $missingTags[] = 'siret';
|
||||||
|
|
||||||
$geojson['features'][] = [
|
$geojson['features'][] = [
|
||||||
'type' => 'Feature',
|
'type' => 'Feature',
|
||||||
'geometry' => [
|
'geometry' => [
|
||||||
|
@ -445,7 +454,9 @@ final class AdminController extends AbstractController
|
||||||
'main_tag' => $commerce->getMainTag(),
|
'main_tag' => $commerce->getMainTag(),
|
||||||
'address' => $commerce->getStreet() . ' ' . $commerce->getHousenumber(),
|
'address' => $commerce->getStreet() . ' ' . $commerce->getHousenumber(),
|
||||||
'note' => $commerce->getNoteContent(),
|
'note' => $commerce->getNoteContent(),
|
||||||
'osm_url' => 'https://www.openstreetmap.org/' . $commerce->getOsmKind() . '/' . $commerce->getOsmId()
|
'osm_url' => 'https://www.openstreetmap.org/' . $commerce->getOsmKind() . '/' . $commerce->getOsmId(),
|
||||||
|
'completion' => $commerce->getCompletionPercentage(),
|
||||||
|
'missing_tags' => $missingTags
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -1955,8 +1966,24 @@ final class AdminController extends AbstractController
|
||||||
}
|
}
|
||||||
unset($points);
|
unset($points);
|
||||||
|
|
||||||
|
|
||||||
|
$now = new \DateTime();
|
||||||
|
$last_week = new \DateTime();
|
||||||
|
$last_week->sub(new \DateInterval('P7D'));
|
||||||
|
|
||||||
|
$adiff_query = '[timeout:60]
|
||||||
|
[adiff:"' . $now->format('Y-m-d') . 'T' . $now->format('H:i:s') . 'Z","2025-08-05T00:00:00Z"][out:xml];
|
||||||
|
area["ref:INSEE"="91111"]->.searchArea;
|
||||||
|
(
|
||||||
|
nwr(area.searchArea);
|
||||||
|
);
|
||||||
|
out meta;';
|
||||||
|
|
||||||
return $this->render('admin/followup_graph.html.twig', [
|
return $this->render('admin/followup_graph.html.twig', [
|
||||||
|
'adiff_query' => $adiff_query,
|
||||||
'stats' => $stats,
|
'stats' => $stats,
|
||||||
|
|
||||||
|
|
||||||
'completion_tags' => \App\Service\FollowUpService::getFollowUpCompletionTags(),
|
'completion_tags' => \App\Service\FollowUpService::getFollowUpCompletionTags(),
|
||||||
'followup_labels' => \App\Service\FollowUpService::getFollowUpThemes(),
|
'followup_labels' => \App\Service\FollowUpService::getFollowUpThemes(),
|
||||||
'followup_icons' => \App\Service\FollowUpService::getFollowUpIcons(),
|
'followup_icons' => \App\Service\FollowUpService::getFollowUpIcons(),
|
||||||
|
|
|
@ -4,69 +4,81 @@
|
||||||
|
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
<link href='{{ asset('css/city-sidebar.css') }}' rel='stylesheet' />
|
<link href='{{ asset('css/city-sidebar.css') }}' rel='stylesheet'/>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<!-- Sidebar de navigation -->
|
<!-- Sidebar de navigation -->
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{% include 'admin/_city_sidebar.html.twig' with {'stats': stats, 'active_menu': 'followup_graph'} %}
|
{% include 'admin/_city_sidebar.html.twig' with {'stats': stats, 'active_menu': 'followup_graph'} %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Contenu principal -->
|
<!-- Contenu principal -->
|
||||||
<div class="col-md-9 col-lg-10 main-content">
|
<div class="col-md-9 col-lg-10 main-content">
|
||||||
<div class="p-4">
|
<div class="p-4">
|
||||||
<h1>Suivi des objets OSM pour {{ stats.name }} ({{ stats.zone }})</h1>
|
<h1>Suivi des objets OSM pour {{ stats.name }} ({{ stats.zone }})</h1>
|
||||||
<div class="mb-3 d-flex flex-wrap gap-2">
|
<div class="mb-3 d-flex flex-wrap gap-2">
|
||||||
<a href="{{ path('admin_followup', {'insee_code': stats.zone}) }}" class="btn btn-warning">
|
<a href="{{ path('admin_followup', {'insee_code': stats.zone}) }}" class="btn btn-warning">
|
||||||
<i class="bi bi-arrow-repeat"></i> Mettre à jour les suivis (followup)
|
<i class="bi bi-arrow-repeat"></i> Mettre à jour les suivis (followup)
|
||||||
</a>
|
</a>
|
||||||
<a href="{{ path('app_admin_labourer', {'insee_code': stats.zone, 'deleteMissing': 1}) }}" class="btn btn-primary">
|
<a href="{{ path('app_admin_labourer', {'insee_code': stats.zone, 'deleteMissing': 1}) }}"
|
||||||
<i class="bi bi-shovel"></i> Labourer la zone
|
class="btn btn-primary">
|
||||||
</a>
|
<i class="bi bi-shovel"></i> Labourer la zone
|
||||||
<a href="{{ path('app_admin_labourer', {'insee_code': stats.zone, 'deleteMissing': 1, 'disableFollowUpCleanup': 1}) }}" class="btn btn-warning" title="Labourer sans nettoyer les suivis OSM">
|
</a>
|
||||||
<i class="bi bi-shield-check"></i> Labourer (sans nettoyage)
|
<a href="{{ path('app_admin_labourer', {'insee_code': stats.zone, 'deleteMissing': 1, 'disableFollowUpCleanup': 1}) }}"
|
||||||
</a>
|
class="btn btn-warning" title="Labourer sans nettoyer les suivis OSM">
|
||||||
<a href="{{ path('app_admin_stats', {'insee_code': stats.zone}) }}" class="btn btn-info">
|
<i class="bi bi-shield-check"></i> Labourer (sans nettoyage)
|
||||||
<i class="bi bi-bar-chart"></i> Voir les stats
|
</a>
|
||||||
</a>
|
<a href="{{ path('app_admin_stats', {'insee_code': stats.zone}) }}" class="btn btn-info">
|
||||||
</div>
|
<i class="bi bi-bar-chart"></i> Voir les stats
|
||||||
<p>Historique des objets suivis (nombre et complétion).</p>
|
</a>
|
||||||
<div id="objets_modified_lately">
|
</div>
|
||||||
{% set has_change = false %}
|
<p>Historique des objets suivis (nombre et complétion).</p>
|
||||||
<table class="table table-bordered table-sm align-middle table-sortable" id="latestDiffsTable">
|
<div id="objets_modified_lately">
|
||||||
<thead>
|
{% set has_change = false %}
|
||||||
<tr>
|
<table class="table table-bordered table-sm align-middle table-sortable" id="latestDiffsTable">
|
||||||
<th>Thème</th>
|
<thead>
|
||||||
<th>Évolution 7j</th>
|
<tr>
|
||||||
<th>Évolution 30j</th>
|
<th>Thème</th>
|
||||||
<th>Évolution 6 mois</th>
|
<th>
|
||||||
</tr>
|
{# <pre> #}
|
||||||
</thead>
|
|
||||||
<tbody>
|
{# {{ dump(adiff_query ) }} #}
|
||||||
{% for type, diff in latest_diffs %}
|
{# </pre> #}
|
||||||
{% set has_period_change = (diff.count_diff_7j != 0 or diff.count_diff_30j != 0 or diff.count_diff_6mois != 0) %}
|
{# <a href="https://overpass-turbo.eu/?Q={{ adiff_query|url_encode }}" target="_blank" #}
|
||||||
{% if has_period_change %}
|
{# title="Voir les changements des 7 derniers jours sur Overpass Turbo">Évolution 7j #}
|
||||||
{% set has_change = true %}
|
{# <i class="bi bi-box-arrow-up-right"></i></a> #}
|
||||||
<tr>
|
</th>
|
||||||
<td>
|
<th>Évolution 30j</th>
|
||||||
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}" class="fw-bold text-decoration-none">
|
<th>Évolution 6 mois</th>
|
||||||
{{ tag_emoji(type) }} {{ diff.label }}
|
</tr>
|
||||||
</a>
|
</thead>
|
||||||
</td>
|
<tbody>
|
||||||
<td>
|
{% for type, diff in latest_diffs %}
|
||||||
{% if diff.count_diff_7j > 0 %}
|
{% set has_period_change = (diff.count_diff_7j != 0 or diff.count_diff_30j != 0 or diff.count_diff_6mois != 0) %}
|
||||||
<i class="bi bi-arrow-up text-success"></i>
|
{% if has_period_change %}
|
||||||
{% elseif diff.count_diff_7j < 0 %}
|
{% set has_change = true %}
|
||||||
<i class="bi bi-arrow-down text-danger"></i>
|
<tr>
|
||||||
{% else %}
|
<td>
|
||||||
<i class="bi bi-arrow-right text-secondary"></i>
|
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}"
|
||||||
{% endif %}
|
class="fw-bold text-decoration-none">
|
||||||
{{ diff.count_diff_7j > 0 ? '+' ~ diff.count_diff_7j : diff.count_diff_7j }} objets
|
{{ tag_emoji(type) }} {{ diff.label }}
|
||||||
<br>
|
</a>
|
||||||
<span class="small text-muted">Complétion :
|
</td>
|
||||||
|
<td>
|
||||||
|
{% if diff.count_diff_7j > 0 %}
|
||||||
|
<i class="bi bi-arrow-up text-success"></i>
|
||||||
|
{% elseif diff.count_diff_7j < 0 %}
|
||||||
|
<i class="bi bi-arrow-down text-danger"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="bi bi-arrow-right text-secondary"></i>
|
||||||
|
{% endif %}
|
||||||
|
{{ diff.count_diff_7j > 0 ? '+' ~ diff.count_diff_7j : diff.count_diff_7j }}
|
||||||
|
objets
|
||||||
|
<br>
|
||||||
|
<span class="small text-muted">Complétion :
|
||||||
{% if diff.completion_diff_7j > 0 %}
|
{% if diff.completion_diff_7j > 0 %}
|
||||||
<i class="bi bi-arrow-up text-success"></i>
|
<i class="bi bi-arrow-up text-success"></i>
|
||||||
{% elseif diff.completion_diff_7j < 0 %}
|
{% elseif diff.completion_diff_7j < 0 %}
|
||||||
|
@ -74,20 +86,21 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="bi bi-arrow-right text-secondary"></i>
|
<i class="bi bi-arrow-right text-secondary"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ diff.completion_diff_7j > 0 ? '+' ~ diff.completion_diff_7j : diff.completion_diff_7j }}%
|
{{ diff.completion_diff_7j > 0 ? '+' ~ diff.completion_diff_7j : diff.completion_diff_7j }}%
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if diff.count_diff_30j > 0 %}
|
{% if diff.count_diff_30j > 0 %}
|
||||||
<i class="bi bi-arrow-up text-success"></i>
|
<i class="bi bi-arrow-up text-success"></i>
|
||||||
{% elseif diff.count_diff_30j < 0 %}
|
{% elseif diff.count_diff_30j < 0 %}
|
||||||
<i class="bi bi-arrow-down text-danger"></i>
|
<i class="bi bi-arrow-down text-danger"></i>
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="bi bi-arrow-right text-secondary"></i>
|
<i class="bi bi-arrow-right text-secondary"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ diff.count_diff_30j > 0 ? '+' ~ diff.count_diff_30j : diff.count_diff_30j }} objets
|
{{ diff.count_diff_30j > 0 ? '+' ~ diff.count_diff_30j : diff.count_diff_30j }}
|
||||||
<br>
|
objets
|
||||||
<span class="small text-muted">Complétion :
|
<br>
|
||||||
|
<span class="small text-muted">Complétion :
|
||||||
{% if diff.completion_diff_30j > 0 %}
|
{% if diff.completion_diff_30j > 0 %}
|
||||||
<i class="bi bi-arrow-up text-success"></i>
|
<i class="bi bi-arrow-up text-success"></i>
|
||||||
{% elseif diff.completion_diff_30j < 0 %}
|
{% elseif diff.completion_diff_30j < 0 %}
|
||||||
|
@ -95,20 +108,21 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="bi bi-arrow-right text-secondary"></i>
|
<i class="bi bi-arrow-right text-secondary"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ diff.completion_diff_30j > 0 ? '+' ~ diff.completion_diff_30j : diff.completion_diff_30j }}%
|
{{ diff.completion_diff_30j > 0 ? '+' ~ diff.completion_diff_30j : diff.completion_diff_30j }}%
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if diff.count_diff_6mois > 0 %}
|
{% if diff.count_diff_6mois > 0 %}
|
||||||
<i class="bi bi-arrow-up text-success"></i>
|
<i class="bi bi-arrow-up text-success"></i>
|
||||||
{% elseif diff.count_diff_6mois < 0 %}
|
{% elseif diff.count_diff_6mois < 0 %}
|
||||||
<i class="bi bi-arrow-down text-danger"></i>
|
<i class="bi bi-arrow-down text-danger"></i>
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="bi bi-arrow-right text-secondary"></i>
|
<i class="bi bi-arrow-right text-secondary"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ diff.count_diff_6mois > 0 ? '+' ~ diff.count_diff_6mois : diff.count_diff_6mois }} objets
|
{{ diff.count_diff_6mois > 0 ? '+' ~ diff.count_diff_6mois : diff.count_diff_6mois }}
|
||||||
<br>
|
objets
|
||||||
<span class="small text-muted">Complétion :
|
<br>
|
||||||
|
<span class="small text-muted">Complétion :
|
||||||
{% if diff.completion_diff_6mois > 0 %}
|
{% if diff.completion_diff_6mois > 0 %}
|
||||||
<i class="bi bi-arrow-up text-success"></i>
|
<i class="bi bi-arrow-up text-success"></i>
|
||||||
{% elseif diff.completion_diff_6mois < 0 %}
|
{% elseif diff.completion_diff_6mois < 0 %}
|
||||||
|
@ -116,225 +130,248 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="bi bi-arrow-right text-secondary"></i>
|
<i class="bi bi-arrow-right text-secondary"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ diff.completion_diff_6mois > 0 ? '+' ~ diff.completion_diff_6mois : diff.completion_diff_6mois }}%
|
{{ diff.completion_diff_6mois > 0 ? '+' ~ diff.completion_diff_6mois : diff.completion_diff_6mois }}%
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if not has_change %}
|
{% if not has_change %}
|
||||||
<tr><td colspan="4" class="text-muted">Aucun changement significatif cette semaine.</td></tr>
|
<tr>
|
||||||
{% endif %}
|
<td colspan="4" class="text-muted">Aucun changement significatif cette semaine.</td>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
{% endif %}
|
||||||
</div>
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% for type, label in followup_labels %}
|
{% for type, label in followup_labels %}
|
||||||
<h2 id="title-{{ type }}"><i class="bi {{ followup_icons[type]|default('bi-question-circle') }} fs-2"></i> {{ label }}</h2>
|
<h2 id="title-{{ type }}"><i
|
||||||
<canvas id="{{ type }}Chart" width="600" height="400"></canvas>
|
class="bi {{ followup_icons[type]|default('bi-question-circle') }} fs-2"></i> {{ label }}
|
||||||
<div class="mb-3">
|
</h2>
|
||||||
{% set overpass_query = '[out:json][timeout:60];\narea["ref:INSEE"="' ~ stats.zone ~ '"]->.searchArea;\n(' ~ followup_overpass[type]|default('') ~ ');\n\n(._;>;);\n\nout meta;\n>;' %}
|
<canvas id="{{ type }}Chart" width="600" height="400"></canvas>
|
||||||
<a href="https://overpass-turbo.eu/?Q={{ overpass_query|url_encode }}" target="_blank" class="btn btn-sm btn-outline-primary me-2">
|
<div class="mb-3">
|
||||||
<i class="bi bi-geo"></i> Voir sur Overpass Turbo
|
{% set overpass_query = '[out:json][timeout:60];\narea["ref:INSEE"="' ~ stats.zone ~ '"]->.searchArea;\n(' ~ followup_overpass[type]|default('') ~ ');\n\n(._;>;);\n\nout meta;\n>;' %}
|
||||||
</a>
|
<a href="https://overpass-turbo.eu/?Q={{ overpass_query|url_encode }}" target="_blank"
|
||||||
<a href="http://127.0.0.1:8111/import?url=https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}" target="_blank" class="btn btn-sm btn-outline-success">
|
class="btn btn-sm btn-outline-primary me-2">
|
||||||
<i class="bi bi-box-arrow-in-up-right"></i> Ouvrir dans JOSM
|
<i class="bi bi-geo"></i> Voir sur Overpass Turbo
|
||||||
</a>
|
</a>
|
||||||
<a href="{{ path('admin_followup_embed_graph', {'insee_code': stats.zone, 'theme': type}) }}" target="_blank" class="btn btn-sm btn-outline-secondary ms-2">
|
<a href="http://127.0.0.1:8111/import?url=https://overpass-api.de/api/interpreter?data={{ overpass_query|url_encode }}"
|
||||||
<i class="bi bi-code-slash"></i> Version embarquée
|
target="_blank" class="btn btn-sm btn-outline-success">
|
||||||
</a>
|
<i class="bi bi-box-arrow-in-up-right"></i> Ouvrir dans JOSM
|
||||||
</div>
|
</a>
|
||||||
{% include 'admin/_followup_completion_tags.html.twig' with {
|
<a href="{{ path('admin_followup_embed_graph', {'insee_code': stats.zone, 'theme': type}) }}"
|
||||||
'completion_tags': completion_tags,
|
target="_blank" class="btn btn-sm btn-outline-secondary ms-2">
|
||||||
'followup_labels': followup_labels,
|
<i class="bi bi-code-slash"></i> Version embarquée
|
||||||
'all_types': [type]
|
</a>
|
||||||
} %}
|
<a href="{{ path('admin_followup_theme_graph', {'insee_code': stats.zone, 'theme': type}) }}"
|
||||||
{% endfor %}
|
target="_blank" class="btn btn-sm btn-outline-secondary ms-2">
|
||||||
|
<i class="bi bi-graph-up-arrow"></i> Détails
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% include 'admin/_followup_completion_tags.html.twig' with {
|
||||||
|
'completion_tags': completion_tags,
|
||||||
|
'followup_labels': followup_labels,
|
||||||
|
'all_types': [type]
|
||||||
|
} %}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
<h2 class="mt-4">Évolution du taux de complétion (CTC - Complète tes commerces)</h2>
|
<h2 class="mt-4">Évolution du taux de complétion (CTC - Complète tes commerces)</h2>
|
||||||
<canvas id="ctcCompletionChart" width="900" height="400"></canvas>
|
<canvas id="ctcCompletionChart" width="900" height="400"></canvas>
|
||||||
|
|
||||||
<h2 class="mt-4">Données brutes</h2>
|
<h2 class="mt-4">Données brutes</h2>
|
||||||
<table class="table table-bordered table-striped">
|
<table class="table table-bordered table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th>Type</th>
|
<th>Type</th>
|
||||||
<th>Label</th>
|
<th>Label</th>
|
||||||
<th>Valeur</th>
|
<th>Valeur</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for point in all_points %}
|
{% for point in all_points %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ point.date }}</td>
|
<td>{{ point.date }}</td>
|
||||||
<td>{{ point.type }}</td>
|
<td>{{ point.type }}</td>
|
||||||
<td>{{ point.name }}</td>
|
<td>{{ point.name }}</td>
|
||||||
<td>{{ point.value }}</td>
|
<td>{{ point.value }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<a href="{{ path('app_admin_stats', {'insee_code': stats.zone}) }}" class="btn btn-secondary mt-3"><i class="bi bi-arrow-left"></i> Retour à la fiche ville</a>
|
<a href="{{ path('app_admin_stats', {'insee_code': stats.zone}) }}"
|
||||||
|
class="btn btn-secondary mt-3"><i class="bi bi-arrow-left"></i> Retour à la fiche ville</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block javascripts %}
|
{% block javascripts %}
|
||||||
{{ parent() }}
|
{{ parent() }}
|
||||||
<script src="/js/chartjs/chart.umd.js"></script>
|
<script src="/js/chartjs/chart.umd.js"></script>
|
||||||
<script src="/js/chartjs/chartjs-adapter-date-fns.js"></script>
|
<script src="/js/chartjs/chartjs-adapter-date-fns.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2"></script>
|
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-datalabels@2"></script>
|
||||||
<script src="/assets/js/table-sortable.js"></script>
|
<script src="/assets/js/table-sortable.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const series = {{ series|json_encode|raw }};
|
const series = {{ series|json_encode|raw }};
|
||||||
const followupIcons = {{ followup_icons|json_encode|raw }};
|
const followupIcons = {{ followup_icons|json_encode|raw }};
|
||||||
const typeLabels = Object.assign({}, {{ followup_labels|json_encode|raw }});
|
const typeLabels = Object.assign({}, {{ followup_labels|json_encode|raw }});
|
||||||
const ctcCompletionSeries = {% if ctc_completion_series is defined %}{{ ctc_completion_series|json_encode|raw }} {% else %} []{% endif %};
|
const ctcCompletionSeries = {% if ctc_completion_series is defined %}{{ ctc_completion_series|json_encode|raw }} {% else %} []{% endif %};
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
Object.keys(typeLabels).forEach(function(baseType) {
|
Object.keys(typeLabels).forEach(function (baseType) {
|
||||||
const countData = (series[baseType + '_count'] || []).map(pt => ({ x: pt.date, y: pt.value }));
|
const countData = (series[baseType + '_count'] || []).map(pt => ({x: pt.date, y: pt.value}));
|
||||||
const completionData = (series[baseType + '_completion'] || []).map(pt => ({ x: pt.date, y: pt.value }));
|
const completionData = (series[baseType + '_completion'] || []).map(pt => ({x: pt.date, y: pt.value}));
|
||||||
const canvasId = baseType + 'Chart';
|
const canvasId = baseType + 'Chart';
|
||||||
const canvas = document.getElementById(canvasId);
|
const canvas = document.getElementById(canvasId);
|
||||||
if (!canvas) return;
|
if (!canvas) return;
|
||||||
// Derniers points
|
// Derniers points
|
||||||
const lastCount = countData.length ? countData[countData.length - 1].y : '-';
|
const lastCount = countData.length ? countData[countData.length - 1].y : '-';
|
||||||
const lastCompletion = completionData.length ? completionData[completionData.length - 1].y : '-';
|
const lastCompletion = completionData.length ? completionData[completionData.length - 1].y : '-';
|
||||||
// Date de dernière mise à jour
|
// Date de dernière mise à jour
|
||||||
const lastDate = countData.length ? countData[countData.length - 1].x : null;
|
const lastDate = countData.length ? countData[countData.length - 1].x : null;
|
||||||
// Mettre à jour le titre avec l'icône
|
// Mettre à jour le titre avec l'icône
|
||||||
const titleElem = document.getElementById('title-' + baseType);
|
const titleElem = document.getElementById('title-' + baseType);
|
||||||
if (titleElem) {
|
if (titleElem) {
|
||||||
const icon = followupIcons[baseType] || 'bi-question-circle';
|
const icon = followupIcons[baseType] || 'bi-question-circle';
|
||||||
titleElem.innerHTML = `<i class="bi ${icon} fs-2"></i> ${typeLabels[baseType]} ( ${lastCount}, ${lastCompletion}%)`;
|
titleElem.innerHTML = `<i class="bi ${icon} fs-2"></i> ${typeLabels[baseType]} ( ${lastCount}, ${lastCompletion}%)`;
|
||||||
}
|
}
|
||||||
// Créer le graphique
|
// Créer le graphique
|
||||||
new Chart(canvas, {
|
new Chart(canvas, {
|
||||||
type: 'line',
|
type: 'line',
|
||||||
data: {
|
data: {
|
||||||
datasets: [
|
datasets: [
|
||||||
{
|
{
|
||||||
label: 'Nombre',
|
label: 'Nombre',
|
||||||
data: countData,
|
data: countData,
|
||||||
borderColor: 'blue',
|
borderColor: 'blue',
|
||||||
backgroundColor: 'rgba(0,0,255,0.1)',
|
backgroundColor: 'rgba(0,0,255,0.1)',
|
||||||
fill: false,
|
fill: false,
|
||||||
yAxisID: 'y',
|
yAxisID: 'y',
|
||||||
datalabels: {
|
datalabels: {
|
||||||
align: 'top',
|
align: 'top',
|
||||||
anchor: 'end',
|
anchor: 'end',
|
||||||
display: true,
|
display: true,
|
||||||
formatter: function(value) { return value.y; },
|
formatter: function (value) {
|
||||||
font: { weight: 'bold' }
|
return value.y;
|
||||||
}
|
},
|
||||||
},
|
font: {weight: 'bold'}
|
||||||
{
|
}
|
||||||
label: 'Complétion (%)',
|
},
|
||||||
data: completionData,
|
{
|
||||||
borderColor: 'green',
|
label: 'Complétion (%)',
|
||||||
backgroundColor: 'rgba(0,255,0,0.1)',
|
data: completionData,
|
||||||
fill: false,
|
borderColor: 'green',
|
||||||
yAxisID: 'y1',
|
backgroundColor: 'rgba(0,255,0,0.1)',
|
||||||
datalabels: {
|
fill: false,
|
||||||
align: 'bottom',
|
yAxisID: 'y1',
|
||||||
anchor: 'end',
|
datalabels: {
|
||||||
display: true,
|
align: 'bottom',
|
||||||
formatter: function(value) { return value.y + '%'; },
|
anchor: 'end',
|
||||||
font: { weight: 'bold' }
|
display: true,
|
||||||
}
|
formatter: function (value) {
|
||||||
}
|
return value.y + '%';
|
||||||
]
|
},
|
||||||
},
|
font: {weight: 'bold'}
|
||||||
options: {
|
|
||||||
parsing: true,
|
|
||||||
responsive: true,
|
|
||||||
plugins: {
|
|
||||||
title: {
|
|
||||||
display: true,
|
|
||||||
text: `${typeLabels[baseType]} ( ${lastCount}, ${lastCompletion}%)`
|
|
||||||
},
|
|
||||||
datalabels: {
|
|
||||||
display: true
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
callbacks: {
|
|
||||||
title: function(context) {
|
|
||||||
// Affiche la date au survol
|
|
||||||
return context[0].parsed.x ? new Date(context[0].parsed.x).toLocaleString() : '';
|
|
||||||
},
|
|
||||||
label: function(context) {
|
|
||||||
return context.dataset.label + ': ' + context.parsed.y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
},
|
},
|
||||||
scales: {
|
|
||||||
x: { type: 'time', time: { unit: 'day' }, title: { display: true, text: 'Date' } },
|
|
||||||
y: { beginAtZero: true, title: { display: true, text: 'Nombre' } },
|
|
||||||
y1: { beginAtZero: true, position: 'right', title: { display: true, text: 'Complétion (%)' }, grid: { drawOnChartArea: false }, min: 0, max: 100 }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
plugins: [ChartDataLabels]
|
|
||||||
});
|
|
||||||
// Afficher la date de dernière mise à jour sous le graphique
|
|
||||||
if (lastDate) {
|
|
||||||
const dateDiv = document.createElement('div');
|
|
||||||
dateDiv.className = 'text-end text-muted small mb-2';
|
|
||||||
dateDiv.innerHTML = `<i class="bi bi-clock-history"></i> Dernière mise à jour : ${new Date(lastDate).toLocaleString()}`;
|
|
||||||
canvas.parentNode.insertBefore(dateDiv, canvas.nextSibling);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// --- Graphique séparé pour les données CTC ---
|
|
||||||
if (Object.keys(ctcCompletionSeries).length > 0) {
|
|
||||||
const ctcDatasets = Object.keys(ctcCompletionSeries).map(function(type) {
|
|
||||||
return {
|
|
||||||
label: typeLabels[type.replace('_count','')] || type,
|
|
||||||
data: ctcCompletionSeries[type].map(pt => ({ x: pt.date, y: pt.value })),
|
|
||||||
borderColor: 'orange',
|
|
||||||
backgroundColor: 'rgba(255,165,0,0.1)',
|
|
||||||
fill: false,
|
|
||||||
borderDash: [5,3],
|
|
||||||
datalabels: { display: false }
|
|
||||||
};
|
|
||||||
});
|
|
||||||
const ctcCanvas = document.getElementById('ctcCompletionChart');
|
|
||||||
if (ctcCanvas) {
|
|
||||||
new Chart(ctcCanvas, {
|
|
||||||
type: 'line',
|
|
||||||
data: { datasets: ctcDatasets },
|
|
||||||
options: {
|
options: {
|
||||||
parsing: true,
|
parsing: true,
|
||||||
responsive: true,
|
responsive: true,
|
||||||
plugins: {
|
plugins: {
|
||||||
title: {
|
title: {
|
||||||
display: true,
|
display: true,
|
||||||
text: 'Évolution des complétions (CTC)'
|
text: `${typeLabels[baseType]} ( ${lastCount}, ${lastCompletion}%)`
|
||||||
|
},
|
||||||
|
datalabels: {
|
||||||
|
display: true
|
||||||
},
|
},
|
||||||
datalabels: { display: false },
|
|
||||||
tooltip: {
|
tooltip: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
title: function(context) {
|
title: function (context) {
|
||||||
|
// Affiche la date au survol
|
||||||
return context[0].parsed.x ? new Date(context[0].parsed.x).toLocaleString() : '';
|
return context[0].parsed.x ? new Date(context[0].parsed.x).toLocaleString() : '';
|
||||||
},
|
},
|
||||||
label: function(context) {
|
label: function (context) {
|
||||||
return context.dataset.label + ': ' + context.parsed.y;
|
return context.dataset.label + ': ' + context.parsed.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scales: {
|
scales: {
|
||||||
x: { type: 'time', time: { unit: 'day' }, title: { display: true, text: 'Date' } },
|
x: {type: 'time', time: {unit: 'day'}, title: {display: true, text: 'Date'}},
|
||||||
y: { beginAtZero: true, title: { display: true, text: 'Nombre' } }
|
y: {beginAtZero: true, title: {display: true, text: 'Nombre'}},
|
||||||
|
y1: {
|
||||||
|
beginAtZero: true,
|
||||||
|
position: 'right',
|
||||||
|
title: {display: true, text: 'Complétion (%)'},
|
||||||
|
grid: {drawOnChartArea: false},
|
||||||
|
min: 0,
|
||||||
|
max: 100
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
plugins: [ChartDataLabels]
|
plugins: [ChartDataLabels]
|
||||||
});
|
});
|
||||||
|
// Afficher la date de dernière mise à jour sous le graphique
|
||||||
|
if (lastDate) {
|
||||||
|
const dateDiv = document.createElement('div');
|
||||||
|
dateDiv.className = 'text-end text-muted small mb-2';
|
||||||
|
dateDiv.innerHTML = `<i class="bi bi-clock-history"></i> Dernière mise à jour : ${new Date(lastDate).toLocaleString()}`;
|
||||||
|
canvas.parentNode.insertBefore(dateDiv, canvas.nextSibling);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- Graphique séparé pour les données CTC ---
|
||||||
|
if (Object.keys(ctcCompletionSeries).length > 0) {
|
||||||
|
const ctcDatasets = Object.keys(ctcCompletionSeries).map(function (type) {
|
||||||
|
return {
|
||||||
|
label: typeLabels[type.replace('_count', '')] || type,
|
||||||
|
data: ctcCompletionSeries[type].map(pt => ({x: pt.date, y: pt.value})),
|
||||||
|
borderColor: 'orange',
|
||||||
|
backgroundColor: 'rgba(255,165,0,0.1)',
|
||||||
|
fill: false,
|
||||||
|
borderDash: [5, 3],
|
||||||
|
datalabels: {display: false}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
const ctcCanvas = document.getElementById('ctcCompletionChart');
|
||||||
|
if (ctcCanvas) {
|
||||||
|
new Chart(ctcCanvas, {
|
||||||
|
type: 'line',
|
||||||
|
data: {datasets: ctcDatasets},
|
||||||
|
options: {
|
||||||
|
parsing: true,
|
||||||
|
responsive: true,
|
||||||
|
plugins: {
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: 'Évolution des complétions (CTC)'
|
||||||
|
},
|
||||||
|
datalabels: {display: false},
|
||||||
|
tooltip: {
|
||||||
|
callbacks: {
|
||||||
|
title: function (context) {
|
||||||
|
return context[0].parsed.x ? new Date(context[0].parsed.x).toLocaleString() : '';
|
||||||
|
},
|
||||||
|
label: function (context) {
|
||||||
|
return context.dataset.label + ': ' + context.parsed.y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
x: {type: 'time', time: {unit: 'day'}, title: {display: true, text: 'Date'}},
|
||||||
|
y: {beginAtZero: true, title: {display: true, text: 'Nombre'}}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plugins: [ChartDataLabels]
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
</script>
|
||||||
</script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -150,6 +150,60 @@
|
||||||
{{ stats.name }} - {{ stats.completionPercent }}% complété</h1>
|
{{ stats.name }} - {{ stats.completionPercent }}% complété</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="carte" class="section-anchor">
|
||||||
|
<h2>Carte</h2>
|
||||||
|
<div id="maploader">
|
||||||
|
<div class="spinner-border" role="status">
|
||||||
|
<i class="bi bi-load bi-spin"></i>
|
||||||
|
<span class="visually-hidden">Chargement de la carte...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex justify-content-end mb-2">
|
||||||
|
<div class="btn-group" role="group">
|
||||||
|
<button type="button" class="btn btn-outline-primary" id="circleMarkersBtn">
|
||||||
|
<i class="bi bi-circle"></i> Cercles
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-outline-primary active" id="dropMarkersBtn">
|
||||||
|
<i class="bi bi-geo-alt"></i> Gouttes
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button id="btn-geolocate" class="btn btn-outline-primary btn-sm">
|
||||||
|
<i class="bi bi-geo-alt"></i> Me localiser
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div id="map" style="height: 400px; width: 100%; margin-bottom: 1rem;"></div>
|
||||||
|
|
||||||
|
<div id="graphiques" class="section-anchor">
|
||||||
|
<h2>Graphiques</h2>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6 col-12">
|
||||||
|
<canvas id="repartition_tags" width="600" height="400"
|
||||||
|
style="max-width:100%; margin: 20px 0;"></canvas>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-md-6 col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<i class="bi bi-calendar-event"></i> Fréquence des mises à jour par
|
||||||
|
trimestre pour {{ stats.name }}
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<canvas id="modificationsByQuarterChart"
|
||||||
|
style="min-height: 250px; width: 100%;"></canvas>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="attribution">
|
||||||
|
<a href="https://www.openstreetmap.org/copyright">Données OpenStreetMap</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{% if stats.population %}
|
{% if stats.population %}
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-md-4 col-12">
|
<div class="col-md-4 col-12">
|
||||||
|
@ -466,57 +520,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div id="carte" class="section-anchor">
|
|
||||||
<h2>Carte</h2>
|
|
||||||
<div id="maploader">
|
|
||||||
<div class="spinner-border" role="status">
|
|
||||||
<i class="bi bi-load bi-spin"></i>
|
|
||||||
<span class="visually-hidden">Chargement de la carte...</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex justify-content-end mb-2">
|
|
||||||
<div class="btn-group" role="group">
|
|
||||||
<button type="button" class="btn btn-outline-primary" id="circleMarkersBtn">
|
|
||||||
<i class="bi bi-circle"></i> Cercles
|
|
||||||
</button>
|
|
||||||
<button type="button" class="btn btn-outline-primary active" id="dropMarkersBtn">
|
|
||||||
<i class="bi bi-geo-alt"></i> Gouttes
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<button id="btn-geolocate" class="btn btn-outline-primary btn-sm">
|
|
||||||
<i class="bi bi-geo-alt"></i> Me localiser
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div id="map" style="height: 400px; width: 100%; margin-bottom: 1rem;"></div>
|
|
||||||
|
|
||||||
<div id="graphiques" class="section-anchor">
|
|
||||||
<h2>Graphiques</h2>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-md-6 col-12">
|
|
||||||
<canvas id="repartition_tags" width="600" height="400"
|
|
||||||
style="max-width:100%; margin: 20px 0;"></canvas>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col-md-6 col-12">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<i class="bi bi-calendar-event"></i> Fréquence des mises à jour par
|
|
||||||
trimestre pour {{ stats.name }}
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<canvas id="modificationsByQuarterChart"
|
|
||||||
style="min-height: 250px; width: 100%;"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div id="attribution">
|
|
||||||
<a href="https://www.openstreetmap.org/copyright">Données OpenStreetMap</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card mt-4">
|
<div class="card mt-4">
|
||||||
{% include 'admin/stats_history.html.twig' with {stat: stats} %}
|
{% include 'admin/stats_history.html.twig' with {stat: stats} %}
|
||||||
<canvas id="distribution_completion" class="mt-4 mb-4" height="400"></canvas>
|
<canvas id="distribution_completion" class="mt-4 mb-4" height="400"></canvas>
|
||||||
|
@ -718,23 +721,10 @@
|
||||||
document.addEventListener('DOMContentLoaded', function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const geojsonData = {{ geojson|raw }};
|
const geojsonData = {{ geojson|raw }};
|
||||||
const map_token = "{{ maptiler_token }}";
|
const map_token = "{{ maptiler_token }}";
|
||||||
// Liste des tags attendus pour la complétion des lieux
|
// Les valeurs de complétion et tags manquants sont maintenant calculées côté serveur
|
||||||
const completionTags = {{ completion_tags['places']|json_encode|raw }};
|
// et incluses directement dans les données GeoJSON
|
||||||
// Calcul de la complétion et des tags manquants pour chaque lieu
|
|
||||||
geojsonData.features.forEach(f => {
|
geojsonData.features.forEach(f => {
|
||||||
let filled = 0;
|
// Assurons-nous que missing_tags est toujours un tableau
|
||||||
let missing = [];
|
|
||||||
if (completionTags && completionTags.length > 0) {
|
|
||||||
completionTags.forEach(tag => {
|
|
||||||
if (f.properties && typeof f.properties[tag] !== 'undefined' && f.properties[tag] !== null && f.properties[tag] !== '') {
|
|
||||||
filled++;
|
|
||||||
} else {
|
|
||||||
missing.push(tag);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
f.properties.completion = completionTags && completionTags.length > 0 ? Math.round(100 * filled / completionTags.length) : null;
|
|
||||||
// Correction : toujours un tableau
|
|
||||||
f.properties.missing_tags = Array.isArray(f.properties.missing_tags) ? f.properties.missing_tags : (f.properties.missing_tags ? [f.properties.missing_tags] : []);
|
f.properties.missing_tags = Array.isArray(f.properties.missing_tags) ? f.properties.missing_tags : (f.properties.missing_tags ? [f.properties.missing_tags] : []);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue