harmoniser les décomptes de completion sur la page stats

This commit is contained in:
Tykayn 2025-08-18 12:41:31 +02:00 committed by tykayn
parent b9f57e48b5
commit 060b23f87e
3 changed files with 399 additions and 345 deletions

View file

@ -303,11 +303,11 @@ final class AdminController extends AbstractController
return $this->redirectToRoute('app_admin_import_stats');
}
$completion = $stats->getCompletionPercent();
if (!$completion) {
$stats->computeCompletionPercent();
$completion = $stats->getCompletionPercent();
}
// $completion = $stats->getCompletionPercent();
// if (!$completion) {
// $stats->computeCompletionPercent();
// $completion = $stats->getCompletionPercent();
// }
$followups = $stats->getCityFollowUps();
$refresh = false;
if (!$followups->isEmpty()) {
@ -378,7 +378,7 @@ final class AdminController extends AbstractController
// Update the places_count property
$stats->setPlacesCount($stats->getPlaces()->count());
$this->entityManager->persist($stats);
// $this->entityManager->persist($stats);
}
$this->entityManager->flush();
@ -433,6 +433,15 @@ final class AdminController extends AbstractController
if (isset($commerces) && is_iterable($commerces)) {
foreach ($commerces as $commerce) {
if ($commerce->getLat() && $commerce->getLon()) {
// Collect missing tags
$missingTags = [];
if (!$commerce->getName()) $missingTags[] = 'name';
if (!$commerce->hasAddress()) $missingTags[] = 'address';
if (!$commerce->hasOpeningHours()) $missingTags[] = 'opening_hours';
if (!$commerce->hasWebsite()) $missingTags[] = 'website';
if (!$commerce->hasWheelchair()) $missingTags[] = 'wheelchair';
if (!$commerce->getSiret()) $missingTags[] = 'siret';
$geojson['features'][] = [
'type' => 'Feature',
'geometry' => [
@ -445,7 +454,9 @@ final class AdminController extends AbstractController
'main_tag' => $commerce->getMainTag(),
'address' => $commerce->getStreet() . ' ' . $commerce->getHousenumber(),
'note' => $commerce->getNoteContent(),
'osm_url' => 'https://www.openstreetmap.org/' . $commerce->getOsmKind() . '/' . $commerce->getOsmId()
'osm_url' => 'https://www.openstreetmap.org/' . $commerce->getOsmKind() . '/' . $commerce->getOsmId(),
'completion' => $commerce->getCompletionPercentage(),
'missing_tags' => $missingTags
]
];
}
@ -1955,8 +1966,24 @@ final class AdminController extends AbstractController
}
unset($points);
$now = new \DateTime();
$last_week = new \DateTime();
$last_week->sub(new \DateInterval('P7D'));
$adiff_query = '[timeout:60]
[adiff:"' . $now->format('Y-m-d') . 'T' . $now->format('H:i:s') . 'Z","2025-08-05T00:00:00Z"][out:xml];
area["ref:INSEE"="91111"]->.searchArea;
(
nwr(area.searchArea);
);
out meta;';
return $this->render('admin/followup_graph.html.twig', [
'adiff_query' => $adiff_query,
'stats' => $stats,
'completion_tags' => \App\Service\FollowUpService::getFollowUpCompletionTags(),
'followup_labels' => \App\Service\FollowUpService::getFollowUpThemes(),
'followup_icons' => \App\Service\FollowUpService::getFollowUpIcons(),