Commit Graph
3 Commits
Author SHA1 Message Date
Gustavo aa46c3da07 Fix dead manual-send exclusion in campaign candidate query
The real manual-send route (routes/outreach.mjs) always inserts with
produto='' and lead_id=NULL, so the old single NOT EXISTS predicate
(produto = ? AND (lead_id = leads.id OR numero = leads.whatsapp)) could
never match a real manual send's row -- the numero branch was unreachable
in production even though a prior test fabricated a produto value manual
sends never write. Split into two NOT EXISTS clauses: one scoped to
produto+lead_id (automatic/campaign sends), one scoped to numero+
origem='manual' with no produto requirement (manual sends). Updated the
existing regression test to insert the row exactly like the real route
does (produto: '', lead_id: NULL, origem: 'manual').
2026-08-03 13:06:43 -03:00
Gustavo 9bf77d88d3 Fix candidatosEncontrados to reflect full eligible pool, not post-slice count
generateCampaignQueue computed candidatosEncontrados after slicing to
quantidade, so it could never differ from adicionadosNaFila. An operator
generating a queue with quantidade smaller than the eligible pool saw no
signal that more eligible leads existed. Now candidatosEncontrados is read
before the slice, while adicionadosNaFila still reflects rows actually
inserted.
2026-08-01 10:37:31 -03:00
Gustavo 248bd4c550 Add campaign candidate selection, queue generation and approval 2026-08-01 10:32:39 -03:00