refactor: replace if else with ternary operators

This commit is contained in:
José Oliveira 2021-03-24 22:35:05 +00:00 committed by Josh Harvey
parent 92b6093a07
commit accd6d3e15

View file

@ -174,21 +174,18 @@ function getTx (txId, txClass) {
from cash_out_txs txs from cash_out_txs txs
where txs.id=$1` where txs.id=$1`
if (txClass === 'cashIn') { return txClass === 'cashIn'
return db.oneOrNone(cashInSql, [cashInTx.PENDING_INTERVAL, txId]) ? db.oneOrNone(cashInSql, [cashInTx.PENDING_INTERVAL, txId])
} else { : db.oneOrNone(cashOutSql, [txId, REDEEMABLE_AGE])
return db.oneOrNone(cashOutSql, [txId, REDEEMABLE_AGE])
}
} }
function getTxAssociatedData (txId, txClass) { function getTxAssociatedData (txId, txClass) {
const billsSql = `select 'bills' as bills, b.* from bills b where cash_in_txs_id = $1` const billsSql = `select 'bills' as bills, b.* from bills b where cash_in_txs_id = $1`
const actionsSql = `select 'cash_out_actions' as cash_out_actions, actions.* from cash_out_actions actions where tx_id = $1` const actionsSql = `select 'cash_out_actions' as cash_out_actions, actions.* from cash_out_actions actions where tx_id = $1`
if (txClass === 'cashIn') {
return db.manyOrNone(billsSql, [txId]) return txClass === 'cashIn'
} else { ? db.manyOrNone(billsSql, [txId])
return db.manyOrNone(actionsSql, [txId]) : db.manyOrNone(actionsSql, [txId])
}
} }
module.exports = { batch, single, cancel, getCustomerTransactionsBatch, getTx, getTxAssociatedData } module.exports = { batch, single, cancel, getCustomerTransactionsBatch, getTx, getTxAssociatedData }