~singpolyma/jmp-pay

cc6b97555af2de0d7adeb2712ebcf12da9a7ab0c — Stephen Paul Weber 3 years ago 810b55c
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.
1 files changed, 9 insertions(+), 1 deletions(-)

M config.ru
M config.ru => config.ru +9 -1
@@ 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