Actualizar server.js

This commit is contained in:
2026-02-16 07:53:17 +00:00
parent 9ac5a78bfd
commit 4fb4464a0b

View File

@@ -777,13 +777,13 @@ app.delete("/services/:id", authMiddleware, async (req, res) => { try { await po
// ==========================================
setInterval(async () => {
try {
const expiredPings = await pool.query(`
SELECT ap.id, ap.scraped_id, ap.user_id, s.owner_id, s.raw_data
FROM assignment_pings ap
JOIN scraped_services s ON ap.scraped_id = s.id
WHERE ap.status = 'pending' AND ap.expires_at < NOW()
AND s.automation_status = 'in_progress'
`);
const expiredPings = await pool.query(`
            SELECT ap.id, ap.scraped_id, ap.user_id, s.owner_id, s.raw_data
            FROM assignment_pings ap
            JOIN scraped_services s ON ap.scraped_id = s.id
            WHERE ap.status = 'pending' AND ap.expires_at < $1
            AND s.automation_status = 'in_progress'
        `, [new Date()]); // <-- El reloj busca comparando con la hora actual de Node
for (const ping of expiredPings.rows) {
await pool.query("UPDATE assignment_pings SET status = 'expired' WHERE id = $1", [ping.id]);