fix: cambio a vehiculos de los ultimos 10 seg

This commit is contained in:
Juan Felipe Zapata Moreno 2026-01-10 13:01:10 -06:00
parent 85d8961606
commit f26e3c44ac

View File

@ -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 [