fix(sms): manual campaign grace period 30min for link_ready (FIX-4 was never applied)

This commit is contained in:
root 2026-09-01 11:09:41 +00:00
parent 2fda27a329
commit eb1b39e035
1 changed files with 2 additions and 1 deletions

View File

@ -124,8 +124,9 @@ def get_groups_to_manual(conn):
AND og.first_sms_sent_at < NOW() - INTERVAL '3 hours'
AND og.second_sms_sent_at IS NOT NULL)
-- 3. link_ready + next_check в прошлом + нет активных SMS в логе
-- FIX-4: grace period 30 мин — manual не крадёт свежие link_ready до first_campaign
OR (COALESCE(og.notification_status, '') = 'link_ready'
AND (og.next_notification_check_at IS NULL OR og.next_notification_check_at <= NOW())
AND (og.next_notification_check_at IS NULL OR og.next_notification_check_at <= NOW() - INTERVAL '30 minutes')
AND NOT EXISTS (
SELECT 1 FROM sms_campaign_log scl
WHERE scl.order_group_id = og.id