From f26e3c44ace2a77d0f3196025b35f91b4a3bff3a Mon Sep 17 00:00:00 2001 From: Juan Felipe Zapata Moreno Date: Sat, 10 Jan 2026 13:01:10 -0600 Subject: [PATCH] fix: cambio a vehiculos de los ultimos 10 seg --- app/Services/VehicleService.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Services/VehicleService.php b/app/Services/VehicleService.php index a811c8d..324a98c 100644 --- a/app/Services/VehicleService.php +++ b/app/Services/VehicleService.php @@ -119,13 +119,16 @@ public function listarVehiculosRobados(): array /** * Listar detecciones del día desde MySQL - * Muestra solo los últimos 10 registros por arco */ - public function listarDeteccionesDelDia(?string $fecha = null, ?int $arcoId = null, int $limit = 10): array + public function listarDeteccionesDelDia(?string $fecha = null, ?int $arcoId = null, int $segundos = 10): array { $fecha = $fecha ?? now()->format('Y-m-d'); - $query = DailyDetection::delDia($fecha); + // Calcular timestamp hace N segundos + $tiempoLimite = now()->subSeconds($segundos); + + $query = DailyDetection::delDia($fecha) + ->where('fecha_deteccion', '>=', $tiempoLimite); // Filtrar por arco si se especifica if ($arcoId !== null) { @@ -134,7 +137,6 @@ public function listarDeteccionesDelDia(?string $fecha = null, ?int $arcoId = nu $detecciones = $query ->orderBy('fecha_deteccion', 'desc') - ->limit($limit) ->get() ->map(function ($deteccion) { return [