reste routes
This commit is contained in:
parent
46e3e55d57
commit
4890dc8a34
2 changed files with 139 additions and 5 deletions
|
@ -857,10 +857,144 @@ class PublicController extends AbstractController
|
|||
]);
|
||||
}
|
||||
|
||||
#[Route('/villes', name: 'app_public_cities')]
|
||||
public function seeAllCities(): Response{
|
||||
|
||||
#[Route('/cities', name: 'app_public_cities')]
|
||||
public function cities(): Response
|
||||
{
|
||||
$stats = $this->entityManager->getRepository(Stats::class)->findAll();
|
||||
|
||||
return $this->render('public/cities.html.twig', ['stats' => $stats]);
|
||||
// Prepare data for the map
|
||||
$citiesForMap = [];
|
||||
foreach ($stats as $stat) {
|
||||
if ($stat->getZone() !== 'undefined' && preg_match('/^\d+$/', $stat->getZone())) {
|
||||
$citiesForMap[] = [
|
||||
'name' => $stat->getName(),
|
||||
'zone' => $stat->getZone(),
|
||||
'lat' => $stat->getLat(),
|
||||
'lon' => $stat->getLon(),
|
||||
'placesCount' => $stat->getPlacesCount(),
|
||||
'completionPercent' => $stat->getCompletionPercent(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('public/cities.html.twig', [
|
||||
'stats' => $stats,
|
||||
'citiesForMap' => $citiesForMap,
|
||||
'maptiler_token' => $_ENV['MAPTILER_TOKEN'] ?? null,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
#[Route('/rss/demandes', name: 'app_public_rss_demandes')]
|
||||
public function rssDemandes(): Response
|
||||
{
|
||||
$demandes = $this->entityManager->getRepository(Demande::class)->findAllOrderedByCreatedAt();
|
||||
|
||||
$content = $this->renderView('public/rss/demandes.xml.twig', [
|
||||
'demandes' => $demandes,
|
||||
'base_url' => $this->getParameter('router.request_context.host'),
|
||||
]);
|
||||
|
||||
$response = new Response($content);
|
||||
$response->headers->set('Content-Type', 'application/rss+xml');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
#[Route('/rss/city/{insee_code}/demandes', name: 'app_public_rss_city_demandes')]
|
||||
public function rssCityDemandes(string $insee_code): Response
|
||||
{
|
||||
$stats = $this->entityManager->getRepository(Stats::class)->findOneBy(['zone' => $insee_code]);
|
||||
if (!$stats) {
|
||||
throw $this->createNotFoundException('Ville non trouvée');
|
||||
}
|
||||
|
||||
// Récupérer les demandes pour cette ville
|
||||
$demandes = $this->entityManager->getRepository(Demande::class)
|
||||
->createQueryBuilder('d')
|
||||
->where('d.insee = :insee')
|
||||
->setParameter('insee', $insee_code)
|
||||
->orderBy('d.createdAt', 'DESC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
$content = $this->renderView('public/rss/city_demandes.xml.twig', [
|
||||
'demandes' => $demandes,
|
||||
'city' => $stats,
|
||||
'base_url' => $this->getParameter('router.request_context.host'),
|
||||
]);
|
||||
|
||||
$response = new Response($content);
|
||||
$response->headers->set('Content-Type', 'application/rss+xml');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
#[Route('/rss/city/{insee_code}/themes', name: 'app_public_rss_city_themes')]
|
||||
public function rssCityThemes(string $insee_code): Response
|
||||
{
|
||||
$stats = $this->entityManager->getRepository(Stats::class)->findOneBy(['zone' => $insee_code]);
|
||||
if (!$stats) {
|
||||
throw $this->createNotFoundException('Ville non trouvée');
|
||||
}
|
||||
|
||||
// Récupérer les changements thématiques pour cette ville
|
||||
$followups = $stats->getCityFollowUps();
|
||||
$themeChanges = [];
|
||||
|
||||
foreach ($followups as $followup) {
|
||||
$name = $followup->getName();
|
||||
if (str_ends_with($name, '_count')) {
|
||||
$type = substr($name, 0, -6);
|
||||
if (!isset($themeChanges[$type])) {
|
||||
$themeChanges[$type] = [];
|
||||
}
|
||||
$themeChanges[$type][] = $followup;
|
||||
}
|
||||
}
|
||||
|
||||
// Trier les changements par date pour chaque thème
|
||||
foreach ($themeChanges as &$changes) {
|
||||
usort($changes, function ($a, $b) {
|
||||
return $b->getDate() <=> $a->getDate();
|
||||
});
|
||||
}
|
||||
|
||||
$content = $this->renderView('public/rss/city_themes.xml.twig', [
|
||||
'themeChanges' => $themeChanges,
|
||||
'city' => $stats,
|
||||
'base_url' => $this->getParameter('router.request_context.host'),
|
||||
'followup_labels' => \App\Service\FollowUpService::getFollowUpThemes(),
|
||||
]);
|
||||
|
||||
$response = new Response($content);
|
||||
$response->headers->set('Content-Type', 'application/rss+xml');
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
#[Route('/city/{insee_code}/demandes', name: 'app_public_city_demandes')]
|
||||
public function cityDemandes(string $insee_code): Response
|
||||
{
|
||||
$stats = $this->entityManager->getRepository(Stats::class)->findOneBy(['zone' => $insee_code]);
|
||||
if (!$stats) {
|
||||
throw $this->createNotFoundException('Ville non trouvée');
|
||||
}
|
||||
|
||||
// Récupérer les demandes pour cette ville
|
||||
$demandes = $this->entityManager->getRepository(Demande::class)
|
||||
->createQueryBuilder('d')
|
||||
->where('d.insee = :insee')
|
||||
->setParameter('insee', $insee_code)
|
||||
->orderBy('d.createdAt', 'DESC')
|
||||
->getQuery()
|
||||
->getResult();
|
||||
|
||||
return $this->render('public/city_demandes.html.twig', [
|
||||
'demandes' => $demandes,
|
||||
'city' => $stats,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="dataDropdown">
|
||||
<li><a class="dropdown-item" href="{{ path('app_public_dashboard') }}"><i class="bi bi-bar-chart-fill"></i> {{ 'display.stats'|trans }}</a></li>
|
||||
{# <li><a class="dropdown-item" href="{{ path('app_public_cities') }}"><i class="bi bi-geo-alt-fill"></i> Suivi des villes</a></li>#}
|
||||
<li><a class="dropdown-item" href="{{ path('app_public_cities') }}"><i class="bi bi-geo-alt-fill"></i> Suivi des villes</a></li>
|
||||
<li><a class="dropdown-item" href="{{ path('app_public_closed_commerces') }}"><i class="bi bi-x-circle-fill"></i> {{ 'display.closed_commerces'|trans }}</a></li>
|
||||
<li><a class="dropdown-item" href="{{ path('app_public_places_with_note') }}"><i class="bi bi-file-earmark-text"></i> {{ 'display.places_with_note'|trans }}</a></li>
|
||||
<li><a class="dropdown-item" href="{{ path('app_public_latest_changes') }}"><i class="bi bi-clock-fill"></i> {{ 'display.latest_changes'|trans }}</a></li>
|
||||
<li><a class="dropdown-item" href="{{ path('admin_fraicheur_histogramme') }}"><i class="bi bi-clock-history"></i> Fraîcheur de la donnée</a></li>
|
||||
<li><a class="dropdown-item" href="/api/v1/stats/export?pretty=1"><i class="bi bi-download"></i> Export JSON des villes</a></li>
|
||||
<li><a class="dropdown-item" href="/admin/export_csv"><i class="bi bi-filetype-csv"></i> Exporter les villes (CSV)</a></li>
|
||||
{# <li><a class="dropdown-item" href="{{ path('app_public_rss_demandes') }}"><i class="bi bi-rss-fill"></i> Flux RSS des demandes</a></li>#}
|
||||
<li><a class="dropdown-item" href="{{ path('app_public_rss_demandes') }}"><i class="bi bi-rss-fill"></i> Flux RSS des demandes</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue