up décompte lieux

This commit is contained in:
Tykayn 2025-06-29 20:02:51 +02:00 committed by tykayn
parent 4fbdcfc704
commit 4300278f15
2 changed files with 27 additions and 8 deletions

View file

@ -385,20 +385,22 @@ final class AdminController extends AbstractController
// Récupérer les derniers followups pour chaque type
$latestFollowups = [];
$types = [
'fire_hydrant', 'charging_station', 'toilets', 'bus_stop', 'defibrillator', 'camera', 'recycling', 'substation', 'places'
];
$types = array_keys(\App\Service\FollowUpService::getFollowUpThemes());
foreach ($types as $type) {
$count = null;
$completion = null;
foreach ($stats->getCityFollowUps() as $fu) {
if ($fu->getName() === $type . '_count') {
if ($count === null || $fu->getDate() > $count->getDate()) {
if ($count === null) {
$count = $fu;
} else if ($fu->getDate() > $count->getDate()) {
$count = $fu;
}
}
if ($fu->getName() === $type . '_completion') {
if ($completion === null || $fu->getDate() > $completion->getDate()) {
if ($completion === null) {
$completion = $fu;
} else if ($fu->getDate() > $completion->getDate()) {
$completion = $fu;
}
}
@ -412,12 +414,16 @@ final class AdminController extends AbstractController
$completion = null;
foreach ($stats->getCityFollowUps() as $fu) {
if ($fu->getName() === 'places_count') {
if ($count === null || $fu->getDate() > $count->getDate()) {
if ($count === null) {
$count = $fu;
} else if ($fu->getDate() > $count->getDate()) {
$count = $fu;
}
}
if ($fu->getName() === 'places_completion') {
if ($completion === null || $fu->getDate() > $completion->getDate()) {
if ($completion === null) {
$completion = $fu;
} else if ($fu->getDate() > $completion->getDate()) {
$completion = $fu;
}
}

View file

@ -48,6 +48,8 @@ class FollowUpService
}) ?? [];
} elseif ($type === 'bicycle_parking') {
$objects = array_filter($elements, fn($el) => ($el['tags']['amenity'] ?? null) === 'bicycle_parking') ?? [];
} elseif ($type === 'places') {
$objects = [];
} else {
$objects = [];
}
@ -61,10 +63,12 @@ class FollowUpService
// Suivi du nombre
$followupCount = new CityFollowUp();
$followupCount->setName($type . '_count')
->setMeasure(count($data['objects']))
->setMeasure($type === 'places' ? $stats->getPlacesCount() : count($data['objects']))
->setDate($now)
->setStats($stats);
$em->persist($followupCount);
// Suivi de la complétion personnalisé (exemples)
$completed = [];
if ($type === 'fire_hydrant') {
@ -125,6 +129,15 @@ class FollowUpService
return !empty($el['tags']['capacity'] ?? null) || !empty($el['tags']['covered'] ?? null);
});
}
if ($type === 'lieux') {
// Si le type est "lieux", on utilise la méthode completionPercent() de $stats
if (method_exists($stats, 'getCompletionPercent')) {
$completion = $stats->getCompletionPercent();
} else {
$completion = 0;
}
}
$completion = count($data['objects']) > 0 ? round(count($completed) / count($data['objects']) * 100) : 0;
$followupCompletion = new CityFollowUp();
$followupCompletion->setName($type . '_completion')