Actualizar server.js

This commit is contained in:
2026-03-15 17:47:09 +00:00
parent 60a4b7815c
commit 8d407b59f0

View File

@@ -3760,14 +3760,16 @@ setInterval(async () => {
}
}
// --- 2. 🚨 CAZADOR DE URGENCIAS (AHORA IGNORA ARCHIVADOS) 🚨 ---
// --- 2. 🚨 NUEVO: CAZADOR DE URGENCIAS QUE "ENTRAN SOLAS" 🚨 ---
// Buscamos servicios que sean urgentes y que sigan atascados en 'manual' o 'pending'
const pendingUrgent = await client.query(`
SELECT s.id, s.owner_id, s.raw_data, s.provider, s.service_ref, pc.auto_dispatch
FROM scraped_services s
LEFT JOIN provider_credentials pc ON s.owner_id = pc.owner_id AND s.provider = pc.provider
WHERE s.is_urgent = true
AND s.automation_status IN ('manual', 'pending')
AND s.status != 'archived' -- 👈 AQUÍ ESTÁ EL ESCUDO ANTI-ARCHIVADOS
AND s.status != 'archived'
AND s.assigned_to IS NULL -- 👈 EL ESCUDO: Solo si NO tiene operario asignado
`);
for (const svc of pendingUrgent.rows) {