page de détail, ajout de mesures
This commit is contained in:
parent
bcafef75f1
commit
af1233c246
2 changed files with 523 additions and 313 deletions
|
@ -733,12 +733,64 @@ final class AdminController extends AbstractController
|
|||
$center = [$first->getLon(), $first->getLat()];
|
||||
}
|
||||
|
||||
// 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;
|
||||
foreach ($places as $p) {
|
||||
if ($p->getOsmId() === $obj['id'] && $p->getOsmKind() === $obj['osm_kind']) {
|
||||
$place = $p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($place) {
|
||||
foreach ($completionTags as $tag) {
|
||||
// Simple check for name tag
|
||||
if ($tag === 'name' && !empty($place->getName())) {
|
||||
$filledTags++;
|
||||
}
|
||||
// Add more tag checks as needed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$currentCompletion = $totalTags > 0 ? round(($filledTags / $totalTags) * 100) : 0;
|
||||
}
|
||||
|
||||
// Add current data to history if empty
|
||||
if (empty($countData)) {
|
||||
$countData[] = [
|
||||
'date' => (new \DateTime())->format('Y-m-d'),
|
||||
'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,
|
||||
'theme_label' => $themes[$theme],
|
||||
'count_data' => json_encode($countData),
|
||||
'completion_data' => json_encode($completionData),
|
||||
'count_data' => $countData,
|
||||
'completion_data' => $completionData,
|
||||
'current_count' => $currentCount,
|
||||
'current_completion' => $currentCompletion,
|
||||
'icons' => \App\Service\FollowUpService::getFollowUpIcons(),
|
||||
'followup_labels' => $themes,
|
||||
'geojson' => json_encode($geojson),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue