diff --git a/server.js b/server.js index 673d2b9..26ee67f 100644 --- a/server.js +++ b/server.js @@ -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]);