handle missing elements in scripts, simplify stats page

This commit is contained in:
Tykayn 2025-06-01 18:56:01 +02:00 committed by tykayn
parent 1e30f360a1
commit 344e71d38f
9 changed files with 247 additions and 47 deletions

View file

@ -72,7 +72,9 @@ final class AdminController extends AbstractController
return $this->render('admin/stats.html.twig', [
'stats' => $stats,
'zip_code' => $zip_code,
'counters' => $calculatedStats['counters']
'counters' => $calculatedStats['counters'],
'maptiler_token' => $_ENV['MAPTILER_TOKEN'],
'mapbox_token' => $_ENV['MAPBOX_TOKEN'],
]);
}

View file

@ -127,7 +127,7 @@ class PublicController extends AbstractController
{
$place = $this->entityManager->getRepository(Place::class)->findOneBy(['uuid_for_url' => $uuid]);
if (!$place) {
$this->addFlash('warning', 'Ce lien de modification n\'existe pas.');
$this->addFlash('warning', 'Ce lien de modification n\'existe pas.'+$uuid);
return $this->redirectToRoute('app_public_index');
}
@ -152,6 +152,7 @@ class PublicController extends AbstractController
'commerce_overpass' => $commerce_overpass,
'name' => $name,
'commerce' => $place,
'completion_percentage' => $place->getCompletionPercentage(),
'hide_filled_inputs' => $this->hide_filled_inputs,
'excluded_tags_to_render' => $this->motocultrice->excluded_tags_to_render,
'osm_kind' => $place->getOsmKind(),
@ -169,6 +170,8 @@ class PublicController extends AbstractController
$places = $this->entityManager->getRepository(Place::class)->findBy([], ['zip_code' => 'ASC', 'name' => 'ASC']);
return $this->render('public/dashboard.html.twig', [
'controller_name' => 'PublicController',
'mapbox_token' => $_ENV['MAPBOX_TOKEN'],
'maptiler_token' => $_ENV['MAPTILER_TOKEN'],
'stats' => $stats,
'places' => $places,
]);

View file

@ -76,7 +76,29 @@ class Place
#[ORM\Column(nullable: true)]
private ?bool $has_note = null;
public function update_place_from_overpass_data(array $overpass_data) {
public function getCompletionPercentage(): ?int
{
$completion_percentage = 0;
$total_fields = 5;
$filled_fields = 0;
if ($this->has_opening_hours) {
$filled_fields += 1;
}
if ($this->has_address) {
$filled_fields += 1;
}
if ($this->has_website) {
$filled_fields += 1;
}
if ($this->has_wheelchair) {
$filled_fields += 1;
}
if ($this->has_note) {
$filled_fields += 1;
}
return round($filled_fields / $total_fields * 100);
}
public function update_place_from_overpass_data(array $overpass_data) {
$overpass_data = $overpass_data['tags_converted'] ;
// Remplir les clés attendues avec des valeurs par défaut si non définies