diff --git a/scripts/sms_manual_campaign.py b/scripts/sms_manual_campaign.py index 6a30f97..99df6e0 100644 --- a/scripts/sms_manual_campaign.py +++ b/scripts/sms_manual_campaign.py @@ -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