thèmes en plus, graph embed
This commit is contained in:
parent
4300278f15
commit
f4e8c70ead
7 changed files with 327 additions and 9 deletions
|
@ -260,18 +260,32 @@ final class AdminController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/admin/stats/{insee_code}', name: 'app_admin_stats')]
|
||||
public function calculer_stats(string $insee_code): Response
|
||||
#[Route('/admin/stats/{insee_code}', name: 'app_admin_stats', requirements: ['insee_code' => '\\d+'])]
|
||||
public function 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]);
|
||||
$this->addFlash('error', 'Aucune stats trouvée pour ce code INSEE.');
|
||||
return $this->redirectToRoute('app_admin');
|
||||
}
|
||||
// Si aucun followup n'existe, on les régénère automatiquement
|
||||
if ($stats->getCityFollowUps()->isEmpty()) {
|
||||
$followups = $stats->getCityFollowUps();
|
||||
$refresh = false;
|
||||
if (!$followups->isEmpty()) {
|
||||
$latest = null;
|
||||
foreach ($followups as $fu) {
|
||||
if ($latest === null || $fu->getDate() > $latest->getDate()) {
|
||||
$latest = $fu;
|
||||
}
|
||||
}
|
||||
if ($latest && $latest->getDate() < (new \DateTime('-1 day'))) {
|
||||
$refresh = true;
|
||||
}
|
||||
} else {
|
||||
$refresh = true;
|
||||
}
|
||||
if ($refresh) {
|
||||
$this->followUpService->generateCityFollowUps($stats, $this->motocultrice, $this->entityManager);
|
||||
$followups = $stats->getCityFollowUps();
|
||||
}
|
||||
$commerces = $stats->getPlaces();
|
||||
$this->actionLogger->log('stats_de_ville', ['insee_code' => $insee_code, 'nom' => $stats->getZone()]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue