From d29b84ec78f32390a9dedc2aa73309c48bcbdec3 Mon Sep 17 00:00:00 2001 From: Brock H Caldwell Date: Fri, 4 Jul 2025 20:54:49 -0500 Subject: [PATCH] fix: better logging for monitor cleanup --- src/Controller/IndexController.php | 7 ++++--- src/Monitor/Framework/Controller/ApiController.php | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Controller/IndexController.php b/src/Controller/IndexController.php index 7bed2f7..71a8542 100644 --- a/src/Controller/IndexController.php +++ b/src/Controller/IndexController.php @@ -5,6 +5,7 @@ namespace App\Controller; use App\Download\Framework\Repository\DownloadRepository; use App\Monitor\Action\Command\MonitorTvShowCommand; use App\Monitor\Action\Handler\MonitorTvShowHandler; +use App\Monitor\Framework\Scheduler\MonitorDispatcher; use App\Tmdb\Tmdb; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -30,9 +31,9 @@ final class IndexController extends AbstractController } #[Route('/test', name: 'app_test')] - public function test() + public function test(MonitorDispatcher $dispatcher): Response { - $result = $this->monitorTvShowHandler->handle(new MonitorTvShowCommand(355)); - return $this->json($result); + $dispatcher(); + return new Response(); } } diff --git a/src/Monitor/Framework/Controller/ApiController.php b/src/Monitor/Framework/Controller/ApiController.php index a3e2226..8d68c63 100644 --- a/src/Monitor/Framework/Controller/ApiController.php +++ b/src/Monitor/Framework/Controller/ApiController.php @@ -6,8 +6,10 @@ use App\Monitor\Action\Handler\AddMonitorHandler; use App\Monitor\Action\Handler\DeleteMonitorHandler; use App\Monitor\Action\Input\AddMonitorInput; use App\Monitor\Action\Input\DeleteMonitorInput; +use App\Monitor\Framework\Scheduler\MonitorDispatcher; use App\Util\Broadcaster; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Mercure\HubInterface; use Symfony\Component\Routing\Attribute\Route; @@ -50,4 +52,15 @@ class ApiController extends AbstractController 'message' => $response ]); } + + #[Route('/api/monitor/dispatch', name: 'api_monitor_dispatch', methods: ['GET'])] + public function dispatch(MonitorDispatcher $dispatcher): Response + { + $dispatcher(); + + return $this->json([ + 'status' => 200, + 'message' => 'Manually dispatched MonitorDispatcher' + ]); + } }