From c0a1780fcedee8ade31ec726cea63eeb263e4efc Mon Sep 17 00:00:00 2001 From: Tykayn Date: Tue, 15 Jul 2025 21:46:30 +0200 Subject: [PATCH] up labourage nouvelle ville --- assets/styles/app.css | 4 +++ src/Controller/AdminController.php | 14 +++++---- src/Controller/PublicController.php | 12 ++++---- src/Service/FollowUpService.php | 45 ++++++++++++++++------------- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/assets/styles/app.css b/assets/styles/app.css index bc76a06..9a6799b 100644 --- a/assets/styles/app.css +++ b/assets/styles/app.css @@ -179,4 +179,8 @@ table tbody { overflow: auto; display: block; border: solid 3px rgb(255, 255, 255); +} + +#citySuggestions{ + z-index: 10; } \ No newline at end of file diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 58a73ea..53e8fda 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -743,8 +743,10 @@ final class AdminController extends AbstractController } $stats = $this->entityManager->getRepository(Stats::class)->findOneBy(['zone' => $insee_code]); if (!$stats) { - $this->addFlash('error', '3 Aucune stats trouvée pour ce code INSEE.'); - return $this->redirectToRoute('app_public_index'); + $stats = new Stats(); + $stats->setZone($insee_code); + // $this->addFlash('error', '3 Aucune stats trouvée pour ce code INSEE.'); + // return $this->redirectToRoute('app_public_index'); } // Mettre à jour la date de requête de labourage $stats->setDateLabourageRequested(new \DateTime()); @@ -771,10 +773,10 @@ final class AdminController extends AbstractController $this->addFlash('warning', "Le serveur est trop sollicité actuellement (RAM insuffisante). La mise à jour des lieux sera effectuée plus tard automatiquement."); } // Toujours générer les CityFollowUp (mais ne jamais les supprimer) - $themes = \App\Service\FollowUpService::getFollowUpThemes(); - foreach (array_keys($themes) as $theme) { - $this->followUpService->generateCityFollowUps($stats, $this->motocultrice, $this->entityManager, true, $theme); - } + // $themes = \App\Service\FollowUpService::getFollowUpThemes(); + // foreach (array_keys($themes) as $theme) { + // $this->followUpService->generateCityFollowUps($stats, $this->motocultrice, $this->entityManager, true, $theme); + // } $this->entityManager->flush(); return $this->redirectToRoute('app_admin_stats', ['insee_code' => $insee_code]); } diff --git a/src/Controller/PublicController.php b/src/Controller/PublicController.php index 31ea7b9..8b6411f 100644 --- a/src/Controller/PublicController.php +++ b/src/Controller/PublicController.php @@ -458,11 +458,13 @@ class PublicController extends AbstractController $stats = $place->getStats(); if (!$stats) { - $stats = $this->entityManager->getRepository(Stats::class)->findOneBy(['zone' => $place->getZipCode()]); - } - if (!$stats) { - $stats = new Stats(); - $stats->setZone($place->getZipCode()); + $stats_exist = $this->entityManager->getRepository(Stats::class)->findOneBy(['zone' => $place->getZipCode()]); + if ($stats_exist) { + $stats = $stats_exist; + } else { + $stats = new Stats(); + $stats->setZone($place->getZipCode()); + } } $stats->addPlace($place); diff --git a/src/Service/FollowUpService.php b/src/Service/FollowUpService.php index 16c2aeb..29c2c46 100644 --- a/src/Service/FollowUpService.php +++ b/src/Service/FollowUpService.php @@ -86,16 +86,19 @@ class FollowUpService foreach ($types as $type => $data) { // Suivi du nombre - $followupCount = new CityFollowUp(); - $followupCount->setName($type . '_count') - ->setMeasure($type === 'places' ? $stats->getPlacesCount() : count($data['objects'])) - ->setDate($now) - ->setStats($stats); - $em->persist($followupCount); - $persisted++; - if ($persisted % 100 === 0) { - $em->flush(); - $em->clear(); + $measureCount = $type === 'places' ? $stats->getPlacesCount() : count($data['objects']); + if ($measureCount !== null) { + $followupCount = new CityFollowUp(); + $followupCount->setName($type . '_count') + ->setMeasure($measureCount) + ->setDate($now) + ->setStats($stats); + $em->persist($followupCount); + $persisted++; + if ($persisted % 100 === 0) { + $em->flush(); + $em->clear(); + } } // Suivi de la complétion basé sur les tags attendus @@ -139,16 +142,18 @@ class FollowUpService } else { $completion = count($partialCompletions) > 0 ? round(array_sum($partialCompletions) / count($partialCompletions) * 100) : 0; } - $followupCompletion = new CityFollowUp(); - $followupCompletion->setName($type . '_completion') - ->setMeasure($completion) - ->setDate($now) - ->setStats($stats); - $em->persist($followupCompletion); - $persisted++; - if ($persisted % 100 === 0) { - $em->flush(); - $em->clear(); + if ($completion !== null) { + $followupCompletion = new CityFollowUp(); + $followupCompletion->setName($type . '_completion') + ->setMeasure($completion) + ->setDate($now) + ->setStats($stats); + $em->persist($followupCompletion); + $persisted++; + if ($persisted % 100 === 0) { + $em->flush(); + $em->clear(); + } } } $em->flush();