feat: filtrar leads com lembrete futuro tambem no FollowUp

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-07 21:51:44 +00:00
parent 24d63cf233
commit 37164cf2ac

View File

@@ -140,6 +140,10 @@ export async function getFollowupLeads() {
FROM tblleads l
WHERE l.status = 12 AND l.lost = 0 AND l.junk = 0
AND (SELECT MAX(date) FROM tbllead_activity_log WHERE leadid = l.id) >= DATE_SUB(CURDATE(), INTERVAL 60 DAY)
AND NOT EXISTS (
SELECT 1 FROM tblreminders r
WHERE r.rel_id = l.id AND r.rel_type = 'lead' AND r.date > NOW() AND r.isnotified = 0
)
ORDER BY (SELECT MAX(date) FROM tbllead_activity_log WHERE leadid = l.id) ASC
`)
return rows