From 4fbdcfc704699523a84977e1f40c122cc2d2b09b Mon Sep 17 00:00:00 2001 From: Tykayn Date: Sun, 29 Jun 2025 19:38:54 +0200 Subject: [PATCH] =?UTF-8?q?ajout=20de=20suivi=20des=20parkings=20v=C3=A9lo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- labourage.sh | 7 ++++++- src/Controller/FollowUpController.php | 14 ++++++++++++++ src/Service/FollowUpService.php | 9 +++++++++ src/Service/Motocultrice.php | 1 + templates/admin/followup_graph.html.twig | 11 +++++++---- 5 files changed, 37 insertions(+), 5 deletions(-) diff --git a/labourage.sh b/labourage.sh index ea9ee81f..08f3bd09 100644 --- a/labourage.sh +++ b/labourage.sh @@ -1,5 +1,10 @@ #!/bin/bash + +curl -X GET "https://osm-commerces.cipherbliss.com/admin/followup/global" + + + # Les 10 codes postaux des villes les plus peuplées de France codes_insee=( "06088" # Nice @@ -240,5 +245,5 @@ done echo "Traitement terminé pour les codes insee" -curl -X GET "https://osm-commerces.cipherbliss.com/https://127.0.0.1:8000/admin/followup/global" +curl -X GET "https://osm-commerces.cipherbliss.com/admin/followup/global" diff --git a/src/Controller/FollowUpController.php b/src/Controller/FollowUpController.php index 0bb220df..791060bd 100644 --- a/src/Controller/FollowUpController.php +++ b/src/Controller/FollowUpController.php @@ -79,6 +79,13 @@ class FollowUpController extends AbstractController 'name' => $fu->getName(), ]; } + // Tri par date dans chaque série + foreach ($series as &$points) { + usort($points, function($a, $b) { + return strtotime($a['date']) <=> strtotime($b['date']); + }); + } + unset($points); return $this->render('admin/followup_graph.html.twig', [ 'stats' => $stats, 'series' => $series, @@ -126,6 +133,13 @@ class FollowUpController extends AbstractController 'name' => $fu->getName(), ]; } + // Tri par date dans chaque série + foreach ($series as &$points) { + usort($points, function($a, $b) { + return strtotime($a['date']) <=> strtotime($b['date']); + }); + } + unset($points); return $this->render('admin/followup_global_graph.html.twig', [ 'stats' => $stats, 'series' => $series, diff --git a/src/Service/FollowUpService.php b/src/Service/FollowUpService.php index 6a8a894e..3450c0ab 100644 --- a/src/Service/FollowUpService.php +++ b/src/Service/FollowUpService.php @@ -46,6 +46,8 @@ class FollowUpService || ($el['tags']['amenity'] ?? null) === 'clinic' || ($el['tags']['amenity'] ?? null) === 'social_facility'; }) ?? []; + } elseif ($type === 'bicycle_parking') { + $objects = array_filter($elements, fn($el) => ($el['tags']['amenity'] ?? null) === 'bicycle_parking') ?? []; } else { $objects = []; } @@ -118,6 +120,10 @@ class FollowUpService || !empty($tags['email'] ?? null) || !empty($tags['contact:email'] ?? null); }); + } elseif ($type === 'bicycle_parking') { + $completed = array_filter($data['objects'], function($el) { + return !empty($el['tags']['capacity'] ?? null) || !empty($el['tags']['covered'] ?? null); + }); } $completion = count($data['objects']) > 0 ? round(count($completed) / count($data['objects']) * 100) : 0; $followupCompletion = new CityFollowUp(); @@ -231,6 +237,7 @@ class FollowUpService 'school' => 'Écoles', 'police' => 'Commissariats', 'healthcare' => 'Lieux de santé', + 'bicycle_parking' => 'Parkings vélos', 'places' => 'Lieux' ]; } @@ -250,6 +257,7 @@ class FollowUpService 'school' => 'bi-mortarboard', 'police' => 'bi-shield-lock', 'healthcare' => 'bi-hospital', + 'bicycle_parking' => 'bi-bicycle', 'places' => 'bi-geo-alt' ]; } @@ -269,6 +277,7 @@ class FollowUpService 'school' => 'nwr["amenity"="school"](area.searchArea);', 'police' => 'nwr["amenity"="police"](area.searchArea);', '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);', + 'bicycle_parking' => 'nwr["amenity"="bicycle_parking"](area.searchArea);', 'places' => '' ]; } diff --git a/src/Service/Motocultrice.php b/src/Service/Motocultrice.php index 15616284..71750a11 100644 --- a/src/Service/Motocultrice.php +++ b/src/Service/Motocultrice.php @@ -582,6 +582,7 @@ area["ref:INSEE"="$zone"]->.searchArea; nwr["healthcare"="laboratory"](area.searchArea); nwr["amenity"="school"](area.searchArea); nwr["amenity"="police"](area.searchArea); + nwr["amenity"="bicycle_parking"](area.searchArea); ); (._;>;); out meta; diff --git a/templates/admin/followup_graph.html.twig b/templates/admin/followup_graph.html.twig index b6086e08..862c44b6 100644 --- a/templates/admin/followup_graph.html.twig +++ b/templates/admin/followup_graph.html.twig @@ -18,7 +18,7 @@

Historique des objets suivis (nombre et complétion).

{% for type, label in followup_labels %} -

{{ label }}

+

{{ label }}

{% set overpass_query = '[out:json][timeout:60];\narea["ref:INSEE"="' ~ stats.zone ~ '"]->.searchArea;\n(' ~ followup_overpass[type]|default('') ~ ');\n\n(._;>;);\n\nout meta;\n>;' %} @@ -63,6 +63,8 @@