mirror of
https://forge.chapril.org/tykayn/osm-commerces
synced 2025-10-04 17:04:53 +02:00
recompute percent completion if needed on load of city stats
This commit is contained in:
parent
b959c695ae
commit
46f8b3f6ab
1 changed files with 14 additions and 8 deletions
|
@ -302,6 +302,12 @@ final class AdminController extends AbstractController
|
|||
$this->addFlash('error', '1 Aucune stats trouvée pour ce code INSEE. Veuillez d\'abord ajouter la ville.');
|
||||
return $this->redirectToRoute('app_admin_import_stats');
|
||||
}
|
||||
|
||||
$completion = $stats->getCompletionPercent();
|
||||
if (!$completion) {
|
||||
$stats->computeCompletionPercent();
|
||||
$completion = $stats->getCompletionPercent();
|
||||
}
|
||||
$followups = $stats->getCityFollowUps();
|
||||
$refresh = false;
|
||||
if (!$followups->isEmpty()) {
|
||||
|
@ -735,15 +741,15 @@ final class AdminController extends AbstractController
|
|||
|
||||
// Calculate current metrics from objects array (from Overpass data)
|
||||
$currentCount = count($objects);
|
||||
|
||||
|
||||
// Calculate current completion percentage
|
||||
$completionTags = \App\Service\FollowUpService::getFollowUpCompletionTags()[$theme] ?? [];
|
||||
$currentCompletion = 0;
|
||||
|
||||
|
||||
if ($currentCount > 0 && !empty($completionTags)) {
|
||||
$totalTags = count($completionTags) * $currentCount;
|
||||
$filledTags = 0;
|
||||
|
||||
|
||||
foreach ($objects as $obj) {
|
||||
// Get the original Place object to check tags
|
||||
$place = null;
|
||||
|
@ -753,7 +759,7 @@ final class AdminController extends AbstractController
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($place) {
|
||||
foreach ($completionTags as $tag) {
|
||||
// Simple check for name tag
|
||||
|
@ -764,10 +770,10 @@ final class AdminController extends AbstractController
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$currentCompletion = $totalTags > 0 ? round(($filledTags / $totalTags) * 100) : 0;
|
||||
}
|
||||
|
||||
|
||||
// Add current data to history if empty
|
||||
if (empty($countData)) {
|
||||
$countData[] = [
|
||||
|
@ -775,14 +781,14 @@ final class AdminController extends AbstractController
|
|||
'value' => $currentCount
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
if (empty($completionData)) {
|
||||
$completionData[] = [
|
||||
'date' => (new \DateTime())->format('Y-m-d'),
|
||||
'value' => $currentCompletion
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
return $this->render('admin/followup_theme_graph.html.twig', [
|
||||
'stats' => $stats,
|
||||
'theme' => $theme,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue