From 349b45ef83e4b73f29fea460f7165c3841c800b0 Mon Sep 17 00:00:00 2001 From: Tykayn Date: Tue, 9 Sep 2025 15:56:30 +0200 Subject: [PATCH] fix routes --- .gitignore | 1 + src/Controller/WikiController.php | 26 +++++++------ templates/admin/wiki.html.twig | 62 +++++++++++++++++++++++++++++++ templates/base.html.twig | 6 +++ wiki_compare/wiki_pages.csv | 4 +- 5 files changed, 85 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 25d2ccb..3086334 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ public/*.json html_cache/* /html_cache/ +activate \ No newline at end of file diff --git a/src/Controller/WikiController.php b/src/Controller/WikiController.php index 843d794..75363d3 100644 --- a/src/Controller/WikiController.php +++ b/src/Controller/WikiController.php @@ -137,14 +137,14 @@ class WikiController extends AbstractController $alignedSections = []; // First, process common sections (they already have both en and fr) -// if (isset($sectionComparison['common']) && is_array($sectionComparison['common'])) { -// foreach ($sectionComparison['common'] as $section) { -// $alignedSections[] = [ -// 'en' => $section['en'], -// 'fr' => $section['fr'] -// ]; -// } -// } + if (isset($sectionComparison['common']) && is_array($sectionComparison['common'])) { + foreach ($sectionComparison['common'] as $section) { + $alignedSections[] = [ + 'en' => $section['en'], + 'fr' => $section['fr'] + ]; + } + } // Then, process English-only sections and add empty placeholders for French if (isset($sectionComparison['en_only']) && is_array($sectionComparison['en_only'])) { @@ -162,8 +162,8 @@ class WikiController extends AbstractController ]; } } -// -// // Finally, process French-only sections (these will be shown at the end) + + // Finally, process French-only sections (these will be shown at the end) if (isset($sectionComparison['fr_only']) && is_array($sectionComparison['fr_only'])) { foreach ($sectionComparison['fr_only'] as $section) { $alignedSections[] = [ @@ -1040,7 +1040,8 @@ EOT; $globalMetrics = $entry['global_metrics']; // Format date for display - $formattedDate = (new \DateTime($date))->format('Y-m-d'); + $formattedDate = is_string($date) && !empty($date) && $date !== '0' ? + (new \DateTime($date))->format('Y-m-d') : 'N/A'; $metrics['dates'][] = $formattedDate; // Get average staleness score @@ -1061,7 +1062,8 @@ EOT; // Process history entries foreach ($historyEntries as $date => $entry) { // Format date for display - $formattedDate = (new \DateTime($date))->format('Y-m-d'); + $formattedDate = is_string($date) && !empty($date) && $date !== '0' ? + (new \DateTime($date))->format('Y-m-d') : 'N/A'; // If date already exists in metrics, use the same index $dateIndex = array_search($formattedDate, $metrics['dates']); diff --git a/templates/admin/wiki.html.twig b/templates/admin/wiki.html.twig index 076b08b..d71ef4c 100644 --- a/templates/admin/wiki.html.twig +++ b/templates/admin/wiki.html.twig @@ -13,12 +13,74 @@

+
+
+

Pages ayant le plus besoin de mise à jour

+
+ {% set top_pages = [] %} + {% for key, languages in wiki_pages|slice(0, 5) %} + {% if languages['en'] is defined and languages['fr'] is defined %} + {% set score = languages['en'].staleness_score|default(0) %} + {% if score > 20 %} + {% set top_pages = top_pages|merge([{'key': key, 'score': score, 'url': path('app_admin_wiki_compare', {'key': key})}]) %} + {% endif %} + {% endif %} + {% endfor %} + + {% for page in top_pages|sort((a, b) => b.score <=> a.score)|slice(0, 3) %} +
+
+
+
{{ page.key }}
+

Score de décrépitude: + + {{ page.score }} + +

+ Comparer +
+
+
+ {% endfor %} +
+
+
+

Liste des pages wiki

+ +
+ {% set count = 0 %} + {% for key, languages in wiki_pages %} + {% if languages['en'] is defined and languages['fr'] is defined and count < 3 %} + + {% set count = count + 1 %} + {% endif %} + {% endfor %} +

+ Ces pages sont celles qui ont le plus besoin d'une mise à jour +

+
+ {% if wiki_pages_stats is defined %}

Statistiques des pages wiki

diff --git a/templates/base.html.twig b/templates/base.html.twig index a0c4dd6..071fdd8 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -46,6 +46,12 @@ Tableau de bord +