Actualizar server.js
This commit is contained in:
@@ -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(`
|
const pendingUrgent = await client.query(`
|
||||||
SELECT s.id, s.owner_id, s.raw_data, s.provider, s.service_ref, pc.auto_dispatch
|
SELECT s.id, s.owner_id, s.raw_data, s.provider, s.service_ref, pc.auto_dispatch
|
||||||
FROM scraped_services s
|
FROM scraped_services s
|
||||||
LEFT JOIN provider_credentials pc ON s.owner_id = pc.owner_id AND s.provider = pc.provider
|
LEFT JOIN provider_credentials pc ON s.owner_id = pc.owner_id AND s.provider = pc.provider
|
||||||
WHERE s.is_urgent = true
|
WHERE s.is_urgent = true
|
||||||
AND s.automation_status IN ('manual', 'pending')
|
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) {
|
for (const svc of pendingUrgent.rows) {
|
||||||
|
|||||||
Reference in New Issue
Block a user