bin/billing_monthly_cronjob 🔗
@@ -86,7 +86,9 @@ EM::Iterator.new(db.exec(
<<-SQL
SELECT customer_id
FROM customer_plans
- WHERE expires_at <= LOCALTIMESTAMP + '4 days'
+ WHERE
+ expires_at <= LOCALTIMESTAMP + '4 days' AND
+ expires_at > LOCALTIMESTAMP - INTERVAL '1 month'
SQL
), 3).each(nil, -> { one << :done }) do |row, iter|
customer = ExpiringCustomer.new(row["customer_id"])