From cfd67e1e3c787405105b78f7d6da5b5c17be91f5 Mon Sep 17 00:00:00 2001 From: team2 Date: Sun, 1 Mar 2026 17:07:53 +0100 Subject: [PATCH] optimize dashboard --- src/Command/SystemRebuildCommand.php | 32 ++++++++++++++++++------ src/Command/TagHealthCheckCommand.php | 35 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 src/Command/TagHealthCheckCommand.php diff --git a/src/Command/SystemRebuildCommand.php b/src/Command/SystemRebuildCommand.php index 2804f3a..4dbf736 100644 --- a/src/Command/SystemRebuildCommand.php +++ b/src/Command/SystemRebuildCommand.php @@ -11,6 +11,7 @@ use App\Service\IngestJobService; use App\Service\IngestOrchestrator; use App\Tag\TagNdjsonExporter; use App\Tag\TagVectorIndexBuilder; +use App\Tag\TagVectorIndexHealthService; use App\Vector\VectorIndexHealthService; use Symfony\Component\Console\Attribute\AsCommand; use Symfony\Component\Console\Command\Command; @@ -27,13 +28,14 @@ use Symfony\Component\Process\Process; final class SystemRebuildCommand extends Command { public function __construct( - private readonly IngestJobService $jobService, - private readonly IngestOrchestrator $orchestrator, - private readonly TagNdjsonExporter $tagExporter, - private readonly TagVectorIndexBuilder $tagIndexBuilder, - private readonly IndexMetaManager $metaManager, - private readonly VectorIndexHealthService $health, - private readonly string $projectDir, + private readonly IngestJobService $jobService, + private readonly IngestOrchestrator $orchestrator, + private readonly TagNdjsonExporter $tagExporter, + private readonly TagVectorIndexBuilder $tagIndexBuilder, + private readonly IndexMetaManager $metaManager, + private readonly VectorIndexHealthService $health, + private readonly TagVectorIndexHealthService $tagHealth, + private readonly string $projectDir, ) { parent::__construct(); @@ -178,6 +180,13 @@ final class SystemRebuildCommand extends Command return Command::FAILURE; } + try { + $reportTag = $this->tagHealth->check(); + } catch (\Throwable $e) { + $io->error('Tag health check failed: ' . $e->getMessage()); + return Command::FAILURE; + } + $io->definitionList( ['ndjson_exists' => $report['ndjson_exists'] ? 'yes' : 'no'], ['ndjson_chunk_count' => (string)$report['ndjson_chunk_count']], @@ -187,6 +196,15 @@ final class SystemRebuildCommand extends Command ['status' => (string)$report['status']], ); + $io->definitionList( + ['tags_ndjson_exists' => $reportTag['tags_ndjson_exists'] ? 'yes' : 'no'], + ['tags_ndjson_count' => (string)$reportTag['tags_ndjson_count']], + ['tag_vector_exists' => $reportTag['vector_exists'] ? 'yes' : 'no'], + ['tag_meta_exists' => $reportTag['meta_exists'] ? 'yes' : 'no'], + ['vector_tag_count' => (string)$reportTag['vector_tag_count']], + ['status' => (string)$reportTag['status']], + ); + if (!in_array($report['status'], ['OK', 'OK_EMPTY'], true)) { $io->error('Health check not OK: ' . $report['status']); return Command::FAILURE; diff --git a/src/Command/TagHealthCheckCommand.php b/src/Command/TagHealthCheckCommand.php new file mode 100644 index 0000000..d3737f5 --- /dev/null +++ b/src/Command/TagHealthCheckCommand.php @@ -0,0 +1,35 @@ +health->check(); + + $output->writeln(json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); + + return str_starts_with($result['status'], 'OK') + ? Command::SUCCESS + : Command::FAILURE; + } +}