From 42ba84419f572cf5fe6496a49ccd0122cfb9d6d2 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 15 Mar 2021 09:40:30 -0500 Subject: [PATCH] Don't notify when re-processing transaction already in DB --- bin/process_pending_btc_transactions | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/process_pending_btc_transactions b/bin/process_pending_btc_transactions index 82ec479..f23a255 100755 --- a/bin/process_pending_btc_transactions +++ b/bin/process_pending_btc_transactions @@ -213,7 +213,9 @@ class Customer end def add_btc_credit(txid, btc_amount, fiat_amount) - add_transaction(txid, btc_amount, fiat_amount, "Bitcoin payment") + return unless add_transaction( + txid, btc_amount, fiat_amount, "Bitcoin payment" + ) if (bonus = plan.bonus_for(fiat_amount)) add_transaction("bonus_for_#{txid}", bonus, "Bitcoin payment bonus") end @@ -231,7 +233,7 @@ class Customer end def add_transaction(id, amount, note) - DB.exec_params(<<-SQL, [@customer_id, id, amount, note]) + DB.exec_params(<<-SQL, [@customer_id, id, amount, note]).cmd_tuples > 0 INSERT INTO transactions (customer_id, transaction_id, amount, note) VALUES -- 2.45.2