Stats détaillées - {{ stats.name }} ({{ stats.zone }})
+Sélectionnez les thématiques à afficher pour comparer les courbes de décompte et complétion.
+ + +diff --git a/src/Controller/ApiController.php b/src/Controller/ApiController.php index 654b83eb..aec6055f 100644 --- a/src/Controller/ApiController.php +++ b/src/Controller/ApiController.php @@ -332,4 +332,57 @@ class ApiController extends AbstractController ], Response::HTTP_INTERNAL_SERVER_ERROR); } } + + #[Route('/api/v1/stats/{insee}/followup', name: 'api_stats_followup_by_insee', methods: ['GET'])] + public function statsFollowupByInsee(StatsRepository $statsRepository, string $insee): JsonResponse + { + $stats = $statsRepository->findOneBy(['zone' => $insee]); + if (!$stats) { + return new JsonResponse(['error' => 'Zone non trouvée'], Response::HTTP_NOT_FOUND); + } + + $followups = $stats->getCityFollowUps(); + $themes = \App\Service\FollowUpService::getFollowUpThemes(); + + // Organiser les données par thématique + $data = [ + 'city' => [ + 'id' => $stats->getId(), + 'name' => $stats->getName(), + 'zone' => $stats->getZone(), + ], + 'themes' => [] + ]; + + foreach ($themes as $theme => $label) { + $countSeries = []; + $completionSeries = []; + + foreach ($followups as $fu) { + if ($fu->getName() === $theme . '_count') { + $countSeries[] = [ + 'date' => $fu->getDate()->format('Y-m-d'), + 'value' => $fu->getMeasure() + ]; + } elseif ($fu->getName() === $theme . '_completion') { + $completionSeries[] = [ + 'date' => $fu->getDate()->format('Y-m-d'), + 'value' => $fu->getMeasure() + ]; + } + } + + // Trier par date + usort($countSeries, fn($a, $b) => strcmp($a['date'], $b['date'])); + usort($completionSeries, fn($a, $b) => strcmp($a['date'], $b['date'])); + + $data['themes'][$theme] = [ + 'label' => $label, + 'count' => $countSeries, + 'completion' => $completionSeries + ]; + } + + return new JsonResponse($data, Response::HTTP_OK); + } } \ No newline at end of file diff --git a/src/Controller/FollowUpController.php b/src/Controller/FollowUpController.php index 0c24ba4c..5fcf1f87 100644 --- a/src/Controller/FollowUpController.php +++ b/src/Controller/FollowUpController.php @@ -368,4 +368,24 @@ class FollowUpController extends AbstractController 'json_url' => 'https://complete-tes-commerces.fr/13/13001-aix-en-provence/json/aix-en-provence_last_stats.json' ]); } + + #[Route('/admin/followup/{insee_code}/detailed-stats', name: 'admin_followup_detailed_stats', requirements: ['insee_code' => '\\d+'])] + #[Route('/admin/stats/{insee_code}/detailed-stats', name: 'admin_stats_detailed_stats', requirements: ['insee_code' => '\\d+'])] + public function detailedStats( + string $insee_code, + EntityManagerInterface $em + ): Response + { + $stats = $em->getRepository(Stats::class)->findOneBy(['zone' => $insee_code]); + if (!$stats) { + $this->addFlash('error', 'Aucune stats trouvée pour ce code INSEE.'); + return $this->redirectToRoute('app_admin'); + } + + return $this->render('admin/followup_detailed_stats.html.twig', [ + 'stats' => $stats, + 'followup_labels' => FollowUpService::getFollowUpThemes(), + 'followup_icons' => FollowUpService::getFollowUpIcons(), + ]); + } } diff --git a/src/Service/Motocultrice.php b/src/Service/Motocultrice.php index f82745c7..2a5e241c 100644 --- a/src/Service/Motocultrice.php +++ b/src/Service/Motocultrice.php @@ -626,6 +626,11 @@ area["ref:INSEE"="$zone"]->.searchArea; nwr["amenity"="drinking_water"](area.searchArea); nwr["natural"="tree"](area.searchArea); nw["power"="pole"](area.searchArea); + nwr["manhole"](area.searchArea); + nwr["amenity"="public_bookcase"](area.searchArea); + nwr["leisure"="playground"](area.searchArea); + nwr["amenity"="restaurant"](area.searchArea); + nwr["ref:FR:RNB"](area.searchArea); ); (._;>;); out meta; diff --git a/templates/admin/_city_sidebar.html.twig b/templates/admin/_city_sidebar.html.twig index 73b0b6b7..74980b97 100644 --- a/templates/admin/_city_sidebar.html.twig +++ b/templates/admin/_city_sidebar.html.twig @@ -54,6 +54,9 @@ Suivi OSM (graphes) + + Stats détaillées (comparatif) + Évolutions des objets diff --git a/templates/admin/followup_detailed_stats.html.twig b/templates/admin/followup_detailed_stats.html.twig new file mode 100644 index 00000000..0531122d --- /dev/null +++ b/templates/admin/followup_detailed_stats.html.twig @@ -0,0 +1,719 @@ +{% extends 'base.html.twig' %} + +{% block title %}Stats détaillées - {{ stats.name }}{% endblock %} + +{% block stylesheets %} + {{ parent() }} + +{% endblock %} + +{% block body %} +
Sélectionnez les thématiques à afficher pour comparer les courbes de décompte et complétion.
+ + +