mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-09 17:02:46 +02:00
followup service refacto
This commit is contained in:
parent
1c2c3575f9
commit
0611b28172
7 changed files with 341 additions and 596 deletions
|
@ -19,17 +19,23 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
|||
use Twig\Environment;
|
||||
use App\Service\ActionLogger;
|
||||
use DateTime;
|
||||
use App\Service\FollowUpService;
|
||||
|
||||
final class AdminController extends AbstractController
|
||||
{
|
||||
|
||||
private FollowUpService $followUpService;
|
||||
|
||||
public function __construct(
|
||||
private EntityManagerInterface $entityManager,
|
||||
private Motocultrice $motocultrice,
|
||||
private BudgetService $budgetService,
|
||||
private Environment $twig,
|
||||
private ActionLogger $actionLogger
|
||||
) {}
|
||||
private ActionLogger $actionLogger,
|
||||
FollowUpService $followUpService
|
||||
) {
|
||||
$this->followUpService = $followUpService;
|
||||
}
|
||||
|
||||
|
||||
#[Route('/admin/labourer-toutes-les-zones', name: 'app_admin_labourer_tout')]
|
||||
|
@ -230,6 +236,9 @@ final class AdminController extends AbstractController
|
|||
}
|
||||
$this->entityManager->flush();
|
||||
|
||||
// Générer les suivis (followups) après la mise à jour des Places
|
||||
$this->followUpService->generateCityFollowUps($stats, $this->motocultrice, $this->entityManager);
|
||||
|
||||
$message = 'Labourage terminé avec succès. ' . $processedCount . ' nouveaux lieux traités.';
|
||||
if ($updateExisting) {
|
||||
$message .= ' ' . $updatedCount . ' lieux existants mis à jour pour la zone ' . $stats->getName() . ' (' . $stats->getZone() . ').';
|
||||
|
@ -239,8 +248,6 @@ final class AdminController extends AbstractController
|
|||
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Labourage des ' . count($stats_all) . ' zones terminé avec succès.');
|
||||
return $this->redirectToRoute('app_public_dashboard');
|
||||
}
|
||||
|
@ -256,15 +263,17 @@ final class AdminController extends AbstractController
|
|||
#[Route('/admin/stats/{insee_code}', name: 'app_admin_stats')]
|
||||
public function calculer_stats(string $insee_code): Response
|
||||
{
|
||||
|
||||
// Récupérer les stats existantes pour la zone
|
||||
$stats = $this->entityManager->getRepository(Stats::class)->findOneBy(['zone' => $insee_code]);
|
||||
if (!$stats) {
|
||||
// Si aucune statistique n'existe pour cette zone, rediriger vers le labourage de la zone
|
||||
return $this->redirectToRoute('app_admin_labourer', ['insee_code' => $insee_code]);
|
||||
}
|
||||
// Si aucun followup n'existe, on les régénère automatiquement
|
||||
if ($stats->getCityFollowUps()->isEmpty()) {
|
||||
$this->followUpService->generateCityFollowUps($stats, $this->motocultrice, $this->entityManager);
|
||||
}
|
||||
$commerces = $stats->getPlaces();
|
||||
|
||||
$this->actionLogger->log('stats_de_ville', ['insee_code' => $insee_code, 'nom' => $stats->getZone()]);
|
||||
// Récupérer tous les commerces de la zone
|
||||
// $commerces = $this->entityManager->getRepository(Place::class)->findBy(['zip_code' => $insee_code, 'dead' => false]);
|
||||
|
@ -428,7 +437,9 @@ final class AdminController extends AbstractController
|
|||
'CTC_urls' => $urls,
|
||||
'overpass' => '',
|
||||
'podium_local' => $podium_local,
|
||||
'latestFollowups' => $latestFollowups
|
||||
'latestFollowups' => $latestFollowups,
|
||||
'followup_labels' => \App\Service\FollowUpService::getFollowUpThemes(),
|
||||
'followup_icons' => \App\Service\FollowUpService::getFollowUpIcons(),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -858,6 +869,9 @@ final class AdminController extends AbstractController
|
|||
$this->entityManager->persist($stats);
|
||||
$this->entityManager->flush();
|
||||
|
||||
// Générer les suivis (followups) après la mise à jour des Places
|
||||
$this->followUpService->generateCityFollowUps($stats, $this->motocultrice, $this->entityManager);
|
||||
|
||||
$message = 'Labourage terminé avec succès. ' . $processedCount . ' nouveaux lieux traités.';
|
||||
if ($updateExisting) {
|
||||
$message .= ' ' . $updatedCount . ' lieux existants mis à jour.';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue