@@ 170,16 170,23 @@ end
class UnknownTransactions
def self.from(customer_id, address, tx_hashes)
+ self.for(
+ customer_id,
+ fetch_rows_for(address, tx_hashes).map { |row| row["transaction_id"] }
+ )
+ end
+
+ def self.fetch_rows_for(address, tx_hashes)
values = tx_hashes.map do |tx_hash|
"('#{DB.escape_string(tx_hash)}/#{DB.escape_string(address)}')"
end
- rows = DB.exec_params(<<-SQL)
+ return [] unless values
+ DB.exec_params(<<-SQL)
SELECT transaction_id FROM
(VALUES #{values.join(',')}) AS t(transaction_id)
LEFT JOIN transactions USING (transaction_id)
WHERE transactions.transaction_id IS NULL
SQL
- self.for(customer_id, rows.map { |row| row["transaction_id"] })
end
def self.for(customer_id, transaction_ids)