Only try to catch up possible renewals if expired less than 3 months
1 files changed, 4 insertions(+), 1 deletions(-) M sgx_jmp.rb
M sgx_jmp.rb => sgx_jmp.rb +4 -1
@@ 202,7 202,10 @@ def catchup_notify_possible_renewal(db) db.query(<<~SQL).each do |c| SELECT customer_id FROM customer_plans INNER JOIN balances USING (customer_id) WHERE expires_at < LOCALTIMESTAMP AND balance >= 5 WHERE expires_at < LOCALTIMESTAMP AND expires_at >= LOCALTIMESTAMP - INTERVAL '3 months' AND balance >= 5 SQL db.query("SELECT pg_notify('possible_renewal', $1)", c.values) end