<?php

declare(strict_types=1);

namespace App\Controller\Admin;

use App\Index\IndexMetaManager;
use App\Ingest\IngestFlow;
use App\Tag\TagVectorIndexHealthService;
use App\Vector\VectorIndexHealthService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;

final class DashboardController extends AbstractController
{
    #[Route('', name: 'admin_dashboard_null')]
    #[Route('/', name: 'admin_dashboard_trail')]
    #[Route('/admin', name: 'admin_dashboard_alias')]
    public function redirectToDashboard(): RedirectResponse
    {
        return $this->redirectToRoute('admin_dashboard');
    }

    #[Route('/admin/dashboard', name: 'admin_dashboard', methods: ['GET'])]
    public function dashboard(
        IndexMetaManager $metaManager,
        VectorIndexHealthService $health,
        TagVectorIndexHealthService $tagHealth
    ): Response {
        return $this->render('admin/dashboard/index.html.twig', [
            'chunkCount' => $metaManager->getRuntimeChunkCount(),
            'chunkLimit' => IngestFlow::CHUNK_LIMIT_HARD,
            'vectorHealth' => $health->check(),
            'tagVectorHealth' => $tagHealth->check(),
        ]);
    }
}