diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php
index b23a0de..a6fd01f 100644
--- a/src/Controller/AdminController.php
+++ b/src/Controller/AdminController.php
@@ -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(),
diff --git a/templates/admin/followup_graph.html.twig b/templates/admin/followup_graph.html.twig
index 7efc4fe..780ba22 100644
--- a/templates/admin/followup_graph.html.twig
+++ b/templates/admin/followup_graph.html.twig
@@ -4,69 +4,81 @@
{% block stylesheets %}
{{ parent() }}
-
+
{% endblock %}
{% block body %}
-
-
-
-
- {% include 'admin/_city_sidebar.html.twig' with {'stats': stats, 'active_menu': 'followup_graph'} %}
-
+
+
+
+
+ {% include 'admin/_city_sidebar.html.twig' with {'stats': stats, 'active_menu': 'followup_graph'} %}
+
-
-
-
-
Suivi des objets OSM pour {{ stats.name }} ({{ stats.zone }})
-
-
Historique des objets suivis (nombre et complétion).
-
- {% set has_change = false %}
-
-
-
- Thème |
- Évolution 7j |
- Évolution 30j |
- Évolution 6 mois |
-
-
-
- {% for type, diff in latest_diffs %}
- {% set has_period_change = (diff.count_diff_7j != 0 or diff.count_diff_30j != 0 or diff.count_diff_6mois != 0) %}
- {% if has_period_change %}
- {% set has_change = true %}
-
-
-
- {{ tag_emoji(type) }} {{ diff.label }}
-
- |
-
- {% if diff.count_diff_7j > 0 %}
-
- {% elseif diff.count_diff_7j < 0 %}
-
- {% else %}
-
- {% endif %}
- {{ diff.count_diff_7j > 0 ? '+' ~ diff.count_diff_7j : diff.count_diff_7j }} objets
-
- Complétion :
+
+
+
+ Suivi des objets OSM pour {{ stats.name }} ({{ stats.zone }})
+
+ Historique des objets suivis (nombre et complétion).
+
+ {% set has_change = false %}
+
+
+
+ Thème |
+
+ {# #}
+
+ {# {{ dump(adiff_query ) }} #}
+ {# #}
+ {# Évolution 7j #}
+ {# #}
+ |
+ Évolution 30j |
+ Évolution 6 mois |
+
+
+
+ {% for type, diff in latest_diffs %}
+ {% set has_period_change = (diff.count_diff_7j != 0 or diff.count_diff_30j != 0 or diff.count_diff_6mois != 0) %}
+ {% if has_period_change %}
+ {% set has_change = true %}
+
+
+
+ {{ tag_emoji(type) }} {{ diff.label }}
+
+ |
+
+ {% if diff.count_diff_7j > 0 %}
+
+ {% elseif diff.count_diff_7j < 0 %}
+
+ {% else %}
+
+ {% endif %}
+ {{ diff.count_diff_7j > 0 ? '+' ~ diff.count_diff_7j : diff.count_diff_7j }}
+ objets
+
+ Complétion :
{% if diff.completion_diff_7j > 0 %}
{% elseif diff.completion_diff_7j < 0 %}
@@ -74,20 +86,21 @@
{% else %}
{% endif %}
- {{ diff.completion_diff_7j > 0 ? '+' ~ diff.completion_diff_7j : diff.completion_diff_7j }}%
+ {{ diff.completion_diff_7j > 0 ? '+' ~ diff.completion_diff_7j : diff.completion_diff_7j }}%
- |
-
- {% if diff.count_diff_30j > 0 %}
-
- {% elseif diff.count_diff_30j < 0 %}
-
- {% else %}
-
- {% endif %}
- {{ diff.count_diff_30j > 0 ? '+' ~ diff.count_diff_30j : diff.count_diff_30j }} objets
-
- Complétion :
+ |
+
+ {% if diff.count_diff_30j > 0 %}
+
+ {% elseif diff.count_diff_30j < 0 %}
+
+ {% else %}
+
+ {% endif %}
+ {{ diff.count_diff_30j > 0 ? '+' ~ diff.count_diff_30j : diff.count_diff_30j }}
+ objets
+
+ Complétion :
{% if diff.completion_diff_30j > 0 %}
{% elseif diff.completion_diff_30j < 0 %}
@@ -95,20 +108,21 @@
{% else %}
{% endif %}
- {{ diff.completion_diff_30j > 0 ? '+' ~ diff.completion_diff_30j : diff.completion_diff_30j }}%
+ {{ diff.completion_diff_30j > 0 ? '+' ~ diff.completion_diff_30j : diff.completion_diff_30j }}%
- |
-
- {% if diff.count_diff_6mois > 0 %}
-
- {% elseif diff.count_diff_6mois < 0 %}
-
- {% else %}
-
- {% endif %}
- {{ diff.count_diff_6mois > 0 ? '+' ~ diff.count_diff_6mois : diff.count_diff_6mois }} objets
-
- Complétion :
+ |
+
+ {% if diff.count_diff_6mois > 0 %}
+
+ {% elseif diff.count_diff_6mois < 0 %}
+
+ {% else %}
+
+ {% endif %}
+ {{ diff.count_diff_6mois > 0 ? '+' ~ diff.count_diff_6mois : diff.count_diff_6mois }}
+ objets
+
+ Complétion :
{% if diff.completion_diff_6mois > 0 %}
{% elseif diff.completion_diff_6mois < 0 %}
@@ -116,225 +130,248 @@
{% else %}
{% endif %}
- {{ diff.completion_diff_6mois > 0 ? '+' ~ diff.completion_diff_6mois : diff.completion_diff_6mois }}%
+ {{ diff.completion_diff_6mois > 0 ? '+' ~ diff.completion_diff_6mois : diff.completion_diff_6mois }}%
- |
-
- {% endif %}
- {% endfor %}
- {% if not has_change %}
- Aucun changement significatif cette semaine. |
- {% endif %}
-
-
-
+ |
+
+ {% endif %}
+ {% endfor %}
+ {% if not has_change %}
+
+ Aucun changement significatif cette semaine. |
+
+ {% endif %}
+
+
+
- {% for type, label in followup_labels %}
-
{{ label }}
-
-
- {% include 'admin/_followup_completion_tags.html.twig' with {
- 'completion_tags': completion_tags,
- 'followup_labels': followup_labels,
- 'all_types': [type]
- } %}
- {% endfor %}
+ {% for type, label in followup_labels %}
+
{{ label }}
+
+
+
+ {% include 'admin/_followup_completion_tags.html.twig' with {
+ 'completion_tags': completion_tags,
+ 'followup_labels': followup_labels,
+ 'all_types': [type]
+ } %}
+ {% endfor %}
-
Évolution du taux de complétion (CTC - Complète tes commerces)
-
+
Évolution du taux de complétion (CTC - Complète tes commerces)
+
-
Données brutes
-
-
-
- Date |
- Type |
- Label |
- Valeur |
-
-
-
- {% for point in all_points %}
-
- {{ point.date }} |
- {{ point.type }} |
- {{ point.name }} |
- {{ point.value }} |
-
- {% endfor %}
-
-
-
Retour à la fiche ville
+
Données brutes
+
+
+
+ Date |
+ Type |
+ Label |
+ Valeur |
+
+
+
+ {% for point in all_points %}
+
+ {{ point.date }} |
+ {{ point.type }} |
+ {{ point.name }} |
+ {{ point.value }} |
+
+ {% endfor %}
+
+
+
Retour à la fiche ville
+
-
{% endblock %}
{% block javascripts %}
-{{ parent() }}
-
-
-
-
-
+
+
+
+
+ });
+
{% endblock %}
diff --git a/templates/admin/stats.html.twig b/templates/admin/stats.html.twig
index dfa6361..665328f 100644
--- a/templates/admin/stats.html.twig
+++ b/templates/admin/stats.html.twig
@@ -150,6 +150,60 @@
{{ stats.name }} - {{ stats.completionPercent }}% complété
+
+
+
+
Carte
+
+
+
+ Chargement de la carte...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{% if stats.population %}
@@ -466,57 +520,6 @@
-
-
Carte
-
-
-
- Chargement de la carte...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
{% include 'admin/stats_history.html.twig' with {stat: stats} %}
@@ -718,23 +721,10 @@
document.addEventListener('DOMContentLoaded', function () {
const geojsonData = {{ geojson|raw }};
const map_token = "{{ maptiler_token }}";
- // Liste des tags attendus pour la complétion des lieux
- const completionTags = {{ completion_tags['places']|json_encode|raw }};
- // Calcul de la complétion et des tags manquants pour chaque lieu
+ // Les valeurs de complétion et tags manquants sont maintenant calculées côté serveur
+ // et incluses directement dans les données GeoJSON
geojsonData.features.forEach(f => {
- let filled = 0;
- let missing = [];
- if (completionTags && completionTags.length > 0) {
- completionTags.forEach(tag => {
- if (f.properties && typeof f.properties[tag] !== 'undefined' && f.properties[tag] !== null && f.properties[tag] !== '') {
- filled++;
- } else {
- missing.push(tag);
- }
- });
- }
- f.properties.completion = completionTags && completionTags.length > 0 ? Math.round(100 * filled / completionTags.length) : null;
- // Correction : toujours un tableau
+ // Assurons-nous que missing_tags est toujours un tableau
f.properties.missing_tags = Array.isArray(f.properties.missing_tags) ? f.properties.missing_tags : (f.properties.missing_tags ? [f.properties.missing_tags] : []);
});