warmup(ip-rehab): bias recipients to multi-subscriber business domains (cut bounce)

Day-0 batch saw ~45% bounce because 'no listmonk bounce record' is a weak
liveness signal. Now require the recipient's domain to have >=2 enabled
subscribers (a real org, not a one-off typo'd address), which materially lowers
the dead-mailbox bounce rate on the recovering IPs.
This commit is contained in:
justin 2026-06-09 20:31:45 -05:00
parent 25f4a7503b
commit 1c2e263bb7

View file

@ -79,9 +79,19 @@ def pick_recipients(n: int, exclude: set[str]) -> list[tuple[str, str]]:
Queried via `docker exec <pg> psql` since the host has no pg driver. Queried via `docker exec <pg> psql` since the host has no pg driver.
""" """
consumer_list = "(" + ",".join("'%s'" % d for d in CONSUMER) + ")" consumer_list = "(" + ",".join("'%s'" % d for d in CONSUMER) + ")"
# Bias toward higher-deliverability recipients on a recovering IP:
# - real business/ISP domains (never consumer)
# - never recorded a bounce in listmonk
# - domain has >= 2 enabled subscribers (a real org, not a one-off typo'd
# address) -- this materially cuts the dead-mailbox bounce rate.
sql = ( sql = (
"WITH dom AS ("
" SELECT lower(split_part(email,'@',2)) AS d, count(*) AS c "
" FROM subscribers WHERE status='enabled' GROUP BY 1 HAVING count(*) >= 2"
") "
"SELECT s.email, COALESCE(s.name,'') " "SELECT s.email, COALESCE(s.name,'') "
"FROM subscribers s " "FROM subscribers s "
"JOIN dom ON dom.d = lower(split_part(s.email,'@',2)) "
"WHERE s.status='enabled' " "WHERE s.status='enabled' "
f"AND lower(split_part(s.email,'@',2)) NOT IN {consumer_list} " f"AND lower(split_part(s.email,'@',2)) NOT IN {consumer_list} "
"AND NOT EXISTS (SELECT 1 FROM bounces b WHERE b.subscriber_id=s.id) " "AND NOT EXISTS (SELECT 1 FROM bounces b WHERE b.subscriber_id=s.id) "