diff --git a/v4_ci4/app/Libraries/Radar/RadarSyncService.php b/v4_ci4/app/Libraries/Radar/RadarSyncService.php index aa3c7c04..3e206f9c 100644 --- a/v4_ci4/app/Libraries/Radar/RadarSyncService.php +++ b/v4_ci4/app/Libraries/Radar/RadarSyncService.php @@ -46,13 +46,17 @@ class RadarSyncService $analyzer = null; $aiStats = ['enabled' => false, 'ran' => 0, 'skipped' => 0, 'errors' => 0, 'note' => '', 'model' => '']; try { - $ai = AiFactory::client(); - if ($ai->isConfigured()) { - $analyzer = new RadarAnalyzeService($ai); - $aiStats['enabled'] = true; - $aiStats['model'] = $ai->model(); + if (! $this->model->hasAnalysisColumns()) { + $aiStats['note'] = 'Colonnes analysis absentes — exécuter sql/MSOP-3-radar-analysis.sql'; } else { - $aiStats['note'] = 'IA non configurée (clé absente)'; + $ai = AiFactory::client(); + if ($ai->isConfigured()) { + $analyzer = new RadarAnalyzeService($ai); + $aiStats['enabled'] = true; + $aiStats['model'] = $ai->model(); + } else { + $aiStats['note'] = 'IA non configurée (clé absente)'; + } } } catch (\Throwable $e) { $aiStats['note'] = $e->getMessage(); diff --git a/v4_ci4/app/Models/RadarModel.php b/v4_ci4/app/Models/RadarModel.php index 5dc56bb8..77c24c2f 100644 --- a/v4_ci4/app/Models/RadarModel.php +++ b/v4_ci4/app/Models/RadarModel.php @@ -201,7 +201,8 @@ class RadarModel public function needsAnalysis(int $threadId): bool { if (! $this->hasAnalysisColumns()) { - return true; + // Sans sql/MSOP-3-radar-analysis.sql on ne lance pas l’IA en boucle. + return false; } $row = $this->db()->table('radar_threads')->select('analysis')->where('id', $threadId)->get()->getRowArray(); diff --git a/v4_ci4/app/Views/radar/index.php b/v4_ci4/app/Views/radar/index.php index 3e0c8915..93985f88 100644 --- a/v4_ci4/app/Views/radar/index.php +++ b/v4_ci4/app/Views/radar/index.php @@ -224,7 +224,7 @@ $statusClass = static function (string $status): string { } function render(threads) { - countEl.textContent = (threads.length || 0) + ' fil(s)'; + if (countEl) countEl.textContent = (threads.length || 0) + ' fil(s)'; if (!threads.length) { root.innerHTML = '
Aucun signal pour l’instant.
'; return;