mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-04 17:04:53 +02:00
up décompte lieux
This commit is contained in:
parent
4fbdcfc704
commit
4300278f15
2 changed files with 27 additions and 8 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue