Only try to bill if expired for under a month

Stephen Paul Weber created

Change summary

bin/billing_monthly_cronjob | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Detailed changes

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"])