From cc6b97555af2de0d7adeb2712ebcf12da9a7ab0c Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Tue, 13 Apr 2021 10:21:09 -0500 Subject: [PATCH] No crash when there are no new transactions to process Found during initial migration, when a request comes in and it turns out there are no new transactions, we should not try to set nothing to Redis since that will throw an exception. --- config.ru | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/config.ru b/config.ru index 67b2fdd..7255143 100644 --- a/config.ru +++ b/config.ru @@ -179,7 +179,11 @@ class UnknownTransactions LEFT JOIN transactions USING (transaction_id) WHERE transactions.transaction_id IS NULL SQL - new(customer_id, rows.map { |row| row["transaction_id"] }) + self.for(customer_id, rows.map { |row| row["transaction_id"] }) + end + + def self.for(customer_id, transaction_ids) + transaction_ids.empty? ? None.new : new(customer_id, transaction_ids) end def initialize(customer_id, transaction_ids) @@ -193,6 +197,10 @@ class UnknownTransactions *@transaction_ids.flat_map { |txid| [txid, @customer_id] } ) end + + class None + def enqueue!; end + end end class JmpPay < Roda -- 2.38.5