fix: uppercasing SQL

fix: remove unnecessary useEffect
fix: transaction polling issue on logout
This commit is contained in:
Sérgio Salgado 2021-06-01 16:29:47 +01:00 committed by Josh Harvey
parent 852bf7b089
commit 9c428a6f8f
4 changed files with 138 additions and 134 deletions

View file

@ -3,25 +3,25 @@ const cashInTx = require('../cash-in/cash-in-tx')
const { CASH_OUT_TRANSACTION_STATES } = require('../cash-out/cash-out-helper')
function transaction() {
const sql = `select distinct * from (
select 'type' as type, 'Cash In' as value union
select 'type' as type, 'Cash Out' as value union
select 'machine' as type, name as value from devices d inner join cash_in_txs t on d.device_id = t.device_id union
select 'machine' as type, name as value from devices d inner join cash_out_txs t on d.device_id = t.device_id union
select 'customer' as type, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') as value
from customers c inner join cash_in_txs t on c.id = t.customer_id
where c.id_card_data::json->>'firstName' is not null or c.id_card_data::json->>'lastName' is not null union
select 'customer' as type, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') as value
from customers c inner join cash_out_txs t on c.id = t.customer_id
where c.id_card_data::json->>'firstName' is not null or c.id_card_data::json->>'lastName' is not null union
select 'fiat' as type, fiat_code as value from cash_in_txs union
select 'fiat' as type, fiat_code as value from cash_out_txs union
select 'crypto' as type, crypto_code as value from cash_in_txs union
select 'crypto' as type, crypto_code as value from cash_out_txs union
select 'address' as type, to_address as value from cash_in_txs union
select 'address' as type, to_address as value from cash_in_txs union
select 'status' as type, ${cashInTx.TRANSACTION_STATES} as value from cash_in_txs union
select 'status' as type, ${CASH_OUT_TRANSACTION_STATES} as value from cash_out_txs
const sql = `SELECT distinct * FROM (
SELECT 'type' AS type, 'Cash In' AS value UNION
SELECT 'type' AS type, 'Cash Out' AS value UNION
SELECT 'machine' AS type, name AS value FROM devices d INNER JOIN cash_in_txs t ON d.device_id = t.device_id UNION
SELECT 'machine' AS type, name AS value FROM devices d INNER JOIN cash_out_txs t ON d.device_id = t.device_id UNION
SELECT 'customer' AS type, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') AS value
FROM customers c INNER JOIN cash_in_txs t ON c.id = t.customer_id
WHERE c.id_card_data::json->>'firstName' IS NOT NULL or c.id_card_data::json->>'lastName' IS NOT NULL UNION
SELECT 'customer' AS type, concat(id_card_data::json->>'firstName', ' ', id_card_data::json->>'lastName') AS value
FROM customers c INNER JOIN cash_out_txs t ON c.id = t.customer_id
WHERE c.id_card_data::json->>'firstName' IS NOT NULL or c.id_card_data::json->>'lastName' IS NOT NULL UNION
SELECT 'fiat' AS type, fiat_code AS value FROM cash_in_txs UNION
SELECT 'fiat' AS type, fiat_code AS value FROM cash_out_txs UNION
SELECT 'crypto' AS type, crypto_code AS value FROM cash_in_txs UNION
SELECT 'crypto' AS type, crypto_code AS value FROM cash_out_txs UNION
SELECT 'address' AS type, to_address AS value FROM cash_in_txs UNION
SELECT 'address' AS type, to_address AS value FROM cash_in_txs UNION
SELECT 'status' AS type, ${cashInTx.TRANSACTION_STATES} AS value FROM cash_in_txs UNION
SELECT 'status' AS type, ${CASH_OUT_TRANSACTION_STATES} AS value FROM cash_out_txs
) f`
return db.any(sql)