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

@ -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