Query Range → FROM: 2026-04-14 00:00:00 TO: 2026-04-17 23:59:59
SELECT tcs.*
FROM tbl_customer_subscriptions tcs
LEFT JOIN (
SELECT
order_id,
MAX(created) AS last_run,
COUNT(*) AS process_count
FROM roku_cron_log
GROUP BY order_id
) log
ON log.order_id = tcs.order_id
WHERE tcs.pg_name = 'roku'
AND tcs.gateway_subscription_id != ''
AND tcs.end_date BETWEEN '2026-04-14 00:00:00' AND '2026-04-17 23:59:59'
AND (log.last_run IS NULL OR log.last_run < NOW() - INTERVAL 8 HOUR)
AND (log.process_count IS NULL OR log.process_count <= 6)
ORDER BY tcs.id DESC
LIMIT 10
Roku Subscription Check Completed ✅