From a56128b7fa5ae6cd587019dd291f02e95cb4811d Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 26 Apr 2022 10:05:18 -0500 Subject: [PATCH] Only try to bill if expired for under a month --- bin/billing_monthly_cronjob | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/billing_monthly_cronjob b/bin/billing_monthly_cronjob index 7fcbc41..bdf5493 100755 --- a/bin/billing_monthly_cronjob +++ b/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"]) -- 2.34.2