liens de thème dans la page de graphe, thèmes bouche d'égout, micro bibliothèque, parc à jeux
This commit is contained in:
parent
0a5814011f
commit
979be016f2
6 changed files with 117 additions and 86 deletions
|
@ -243,13 +243,12 @@ 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() . ').';
|
||||
$themes = \App\Service\FollowUpService::getFollowUpThemes();
|
||||
foreach (array_keys($themes) as $theme) {
|
||||
$this->followUpService->generateCityFollowUps($stats, $this->motocultrice, $this->entityManager, true, $theme);
|
||||
}
|
||||
$this->addFlash('success', $message);
|
||||
$this->entityManager->flush();
|
||||
return $this->redirectToRoute('app_admin_stats', ['insee_code' => $insee_code]);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
@ -649,8 +648,9 @@ final class AdminController extends AbstractController
|
|||
'count_data' => json_encode($countData),
|
||||
'completion_data' => json_encode($completionData),
|
||||
'icons' => \App\Service\FollowUpService::getFollowUpIcons(),
|
||||
'followup_labels' => $themes,
|
||||
'geojson' => json_encode($geojson),
|
||||
'overpass_query' => $overpass_query | "",
|
||||
'overpass_query' => $overpass_query,
|
||||
'josm_url' => $josm_url,
|
||||
'center' => $center,
|
||||
'maptiler_token' => $_ENV['MAPTILER_TOKEN'] ?? null,
|
||||
|
@ -765,7 +765,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)
|
||||
$this->followUpService->generateCityFollowUps($stats, $this->motocultrice, $this->entityManager, true /* disable cleanup: ne supprime rien */);
|
||||
$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]);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class CityFollowUp
|
|||
#[ORM\Column]
|
||||
private ?\DateTime $date = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Stats::class, inversedBy: 'cityFollowUps')]
|
||||
#[ORM\ManyToOne(targetEntity: Stats::class, inversedBy: 'cityFollowUps', cascade: ['persist'])]
|
||||
private ?Stats $stats = null;
|
||||
|
||||
public function getId(): ?int
|
||||
|
|
|
@ -68,6 +68,12 @@ class FollowUpService
|
|||
$objects = [];
|
||||
} elseif ($type === 'power_pole') {
|
||||
$objects = array_filter($elements, fn($el) => ($el['tags']['power'] ?? null) === 'pole') ?? [];
|
||||
} elseif ($type === 'manhole') {
|
||||
$objects = array_filter($elements, fn($el) => ($el['tags']['manhole'] ?? null) === 'manhole') ?? [];
|
||||
} elseif ($type === 'little_free_library') {
|
||||
$objects = array_filter($elements, fn($el) => ($el['tags']['amenity'] ?? null) === 'little_free_library') ?? [];
|
||||
} elseif ($type === 'playground') {
|
||||
$objects = array_filter($elements, fn($el) => ($el['tags']['leisure'] ?? null) === 'playground') ?? [];
|
||||
} else {
|
||||
$objects = [];
|
||||
}
|
||||
|
@ -148,40 +154,8 @@ class FollowUpService
|
|||
$em->flush();
|
||||
$em->clear();
|
||||
|
||||
// Suppression des mesures redondantes (même valeur consécutive, sauf la dernière) - désactivée si $disableCleanup est true
|
||||
if (!$disableCleanup) {
|
||||
$repo = $em->getRepository(CityFollowUp::class);
|
||||
foreach (array_keys(self::getFollowUpThemes()) as $type) {
|
||||
foreach (['_count', '_completion'] as $suffix) {
|
||||
$name = $type . $suffix;
|
||||
$followups = $repo->createQueryBuilder('f')
|
||||
->where('f.stats = :stats')
|
||||
->andWhere('f.name = :name')
|
||||
->setParameter('stats', $stats)
|
||||
->setParameter('name', $name)
|
||||
->orderBy('f.date', 'ASC')
|
||||
->getQuery()->getResult();
|
||||
$toDelete = [];
|
||||
$prev = null;
|
||||
$n = count($followups);
|
||||
foreach ($followups as $i => $fu) {
|
||||
// Si seulement 2 mesures, ne rien supprimer
|
||||
if ($n == 2) {
|
||||
break;
|
||||
}
|
||||
if ($prev && $fu->getMeasure() === $prev->getMeasure() && $i < $n - 1) {
|
||||
$toDelete[] = $prev;
|
||||
}
|
||||
$prev = $fu;
|
||||
}
|
||||
foreach ($toDelete as $del) {
|
||||
$em->remove($del);
|
||||
}
|
||||
}
|
||||
}
|
||||
$em->flush();
|
||||
$em->clear();
|
||||
}
|
||||
// Suppression des mesures redondantes (même valeur consécutive, sauf la dernière) - désactivée définitivement
|
||||
// (aucune suppression de CityFollowUp)
|
||||
}
|
||||
|
||||
public function generateGlobalFollowUps(EntityManagerInterface $em): void
|
||||
|
@ -296,6 +270,9 @@ class FollowUpService
|
|||
'tree' => 'Arbres',
|
||||
'places' => 'Lieux',
|
||||
'power_pole' => 'Poteaux électriques',
|
||||
'manhole' => "Bouche d'égout",
|
||||
'little_free_library' => "Micro bibliothèque",
|
||||
'playground' => "Parc à jeux pour enfants",
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -325,6 +302,9 @@ class FollowUpService
|
|||
'tree' => 'bi-tree',
|
||||
'places' => 'bi-geo-alt',
|
||||
'power_pole' => 'bi-signpost',
|
||||
'manhole' => 'bi-droplet-half',
|
||||
'little_free_library' => 'bi-book',
|
||||
'playground' => 'bi-emoji-smile',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -359,6 +339,9 @@ class FollowUpService
|
|||
'drinking_water' => 'nwr["amenity"="drinking_water"](area.searchArea);',
|
||||
'tree' => 'nwr["natural"="tree"](area.searchArea);',
|
||||
'power_pole' => 'nwr["power"="pole"](area.searchArea);',
|
||||
'manhole' => 'nwr["manhole"](area.searchArea);',
|
||||
'little_free_library' => 'nwr["amenity"="little_free_library"](area.searchArea);',
|
||||
'playground' => 'nwr["leisure"="playground"](area.searchArea);',
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -505,6 +488,9 @@ class FollowUpService
|
|||
'tree' => ['species', 'leaf_type', 'leaf_cycle'],
|
||||
'power_pole' => ['ref', 'material'],
|
||||
'places' => ['name', 'address', 'opening_hours', 'website', 'phone', 'wheelchair', 'siret'],
|
||||
'manhole' => ['manhole', 'location'],
|
||||
'little_free_library' => ['amenity', 'operator'],
|
||||
'playground' => ['playground', 'operator'],
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue