Change summary
bin/billing_monthly_cronjob | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Detailed changes
@@ -88,7 +88,13 @@ EM::Iterator.new(db.exec(
FROM customer_plans
WHERE
expires_at <= LOCALTIMESTAMP + '4 days' AND
- expires_at > LOCALTIMESTAMP - INTERVAL '1 month'
+ expires_at > LOCALTIMESTAMP - INTERVAL '1 month' AND (
+ SELECT COUNT(*)
+ FROM plan_log
+ WHERE
+ customer_id=customer_plans.customer_id AND
+ UPPER(date_range) > LOCALTIMESTAMP + '4 days'
+ ) < 1;
SQL
), 3).each(nil, -> { one << :done }) do |row, iter|
customer = ExpiringCustomer.new(row["customer_id"])