diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 389a35ac..9e5c9039 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -633,6 +633,31 @@ final class AdminController extends AbstractController } $progression7Days['places'] = \App\Service\FollowUpService::calculate7DayProgression($stats, 'places'); + // Construire theme_groups pour inclure tous les thèmes + $allThemes = \App\Service\FollowUpService::getFollowUpThemes(); + $theme_groups = [ + 'emergency' => ['fire_hydrant', 'defibrillator'], + 'transport' => ['bus_stop', 'charging_station', 'bicycle_parking'], + 'healthcare' => ['healthcare', 'laboratory', 'drinking_water'], + 'education' => ['school'], + 'security' => ['police', 'camera'], + 'infrastructure' => ['toilets', 'recycling', 'substation', 'power_pole', 'street_lamp', 'manhole'], + 'mobilier_urbain' => ['bench', 'waste_basket', 'tree', 'advertising_board'], + 'loisirs' => ['playground', 'little_free_library'], + 'commerces' => ['restaurant', 'places'], + 'batiments' => ['building', 'rnb'], + 'divers' => ['email'], + ]; + // Ajouter les thèmes manquants dans une catégorie "divers" + $allGroupedThemes = []; + foreach ($theme_groups as $group => $themes) { + $allGroupedThemes = array_merge($allGroupedThemes, $themes); + } + $missingThemes = array_diff(array_keys($allThemes), $allGroupedThemes); + if (!empty($missingThemes)) { + $theme_groups['divers'] = array_merge($theme_groups['divers'] ?? [], $missingThemes); + } + // --- Ajout : mesures CTC CityFollowUp pour le graphique d'évolution --- $ctc_completion_series = []; foreach ($stats->getCityFollowUps() as $fu) { @@ -673,6 +698,7 @@ final class AdminController extends AbstractController 'ctc_completion_series' => $ctc_completion_series, 'averageUpdateDate' => $averageUpdateDate, 'daysSinceUpdate' => $daysSinceUpdate, + 'theme_groups' => $theme_groups, ]); } diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index 13b97467..216658a7 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -1122,7 +1122,12 @@ class PublicController extends AbstractController $types[$type][] = $fu; } } + // Récupérer tous les thèmes connus pour afficher même ceux sans données + $allThemes = \App\Service\FollowUpService::getFollowUpThemes(); + $allIcons = \App\Service\FollowUpService::getFollowUpIcons(); + $evolutions = []; + // D'abord, traiter les types qui ont des données foreach ($types as $type => $fus) { usort($fus, fn($a, $b) => $a->getDate() <=> $b->getDate()); $latest = end($fus); @@ -1140,6 +1145,23 @@ class PublicController extends AbstractController $evolutions[$type][$label] = $past !== null && $latest ? $latest->getMeasure() - $past : null; } } + // Ensuite, ajouter les thèmes qui n'ont pas encore de données + foreach ($allThemes as $theme => $themeLabel) { + if (!isset($evolutions[$theme])) { + $evolutions[$theme] = [ + 'now' => null + ]; + foreach ($periods as $periodLabel => $date) { + $evolutions[$theme][$periodLabel] = null; + } + } + } + // Trier les évolutions par ordre alphabétique des labels + uksort($evolutions, function($a, $b) use ($allThemes) { + $labelA = $allThemes[$a] ?? $a; + $labelB = $allThemes[$b] ?? $b; + return strcasecmp($labelA, $labelB); + }); // Grouper les lieux par date de modification $places = $stats->getPlaces(); $now = new \DateTime(); @@ -1170,6 +1192,8 @@ class PublicController extends AbstractController 'places_7j' => $places_7j, 'places_30j' => $places_30j, 'places_6mois' => $places_6mois, + 'theme_labels' => $allThemes, + 'theme_icons' => $allIcons, ]); } diff --git a/src/Service/FollowUpService.php b/src/Service/FollowUpService.php index 6efd5804..fce5db81 100644 --- a/src/Service/FollowUpService.php +++ b/src/Service/FollowUpService.php @@ -511,7 +511,7 @@ class FollowUpService 'tree' => ['species', 'leaf_type', 'leaf_cycle'], 'power_pole' => ['ref', 'material'], 'places' => ['name', 'address', 'opening_hours', 'website', 'phone', 'wheelchair', 'ref:FR:SIRET', 'contact:phone', 'contact:email', 'contact:website'], - 'manhole' => ['manhole', 'location'], + 'manhole' => ['manhole'], 'little_free_library' => ['amenity', 'operator'], 'playground' => ['playground', 'operator'], 'restaurant' => ['contact:phone', 'phone', 'contact:email', 'email', 'contact:website', 'website', 'cuisine', 'ref:FR:SIRET'], diff --git a/templates/admin/stats.html.twig b/templates/admin/stats.html.twig index 03d6b9e4..fc1b47a0 100644 --- a/templates/admin/stats.html.twig +++ b/templates/admin/stats.html.twig @@ -282,14 +282,7 @@ 'healthcare': 'nwr["healthcare"](area.searchArea);nwr["amenity"="doctors"](area.searchArea);nwr["amenity"="pharmacy"](area.searchArea);nwr["amenity"="hospital"](area.searchArea);nwr["amenity"="clinic"](area.searchArea);nwr["amenity"="social_facility"](area.searchArea);' } %} - {% set theme_groups = { - 'emergency': ['fire_hydrant', 'defibrillator'], - 'transport': ['bus_stop', 'charging_station', 'bicycle_parking'], - 'healthcare': ['healthcare', 'laboratory', 'drinking_water'], - 'education': ['school'], - 'security': ['police', 'camera'], - 'infrastructure': ['toilets', 'recycling', 'substation'] - } %} + {# theme_groups est maintenant passé depuis le contrôleur pour inclure tous les thèmes #}