diff --git a/api/lab/get_tv_log.php b/api/lab/get_tv_log.php new file mode 100644 index 0000000..da17270 --- /dev/null +++ b/api/lab/get_tv_log.php @@ -0,0 +1,45 @@ +query( + "SELECT evento, COUNT(*) n FROM turnero_tv_log + WHERE created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) + GROUP BY evento" +)->fetchAll(PDO::FETCH_KEY_PAIR); + +// Últimos incidentes (lo normal —start/end— no se lista: solo lo que falló) +$stmt = $pdo->query( + "SELECT evento, detalle, created_at FROM turnero_tv_log + WHERE evento IN ('mudo', 'sin_start', 'error') + ORDER BY id DESC LIMIT 30" +); +$incidentes = []; +foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $r) { + $d = json_decode($r['detalle'] ?? '{}', true) ?: []; + $incidentes[] = [ + 'cuando' => $r['created_at'], + 'evento' => $r['evento'], + 'turno' => $d['cod'] ?? null, + 'voz' => $d['voz'] ?? null, + ]; +} + +$anuncios = (int)($resumen['start'] ?? 0); +$mudos = (int)($resumen['mudo'] ?? 0); +$avisos = (int)($resumen['sin_start'] ?? 0) + (int)($resumen['error'] ?? 0); + +jsonOk([ + 'anuncios_7d' => $anuncios, + 'completos_7d' => (int)($resumen['end'] ?? 0), + 'mudos_7d' => $mudos, + 'avisos_7d' => $avisos, + 'incidentes' => $incidentes, +]); diff --git a/lab_actividad.php b/lab_actividad.php index a466c28..224f31a 100644 --- a/lab_actividad.php +++ b/lab_actividad.php @@ -111,6 +111,18 @@ require_once __DIR__ . '/shared/components/sidebar.php'; + +
+