refactor: replace if else with ternary operators
This commit is contained in:
parent
92b6093a07
commit
accd6d3e15
1 changed files with 7 additions and 10 deletions
|
|
@ -174,21 +174,18 @@ function getTx (txId, txClass) {
|
|||
from cash_out_txs txs
|
||||
where txs.id=$1`
|
||||
|
||||
if (txClass === 'cashIn') {
|
||||
return db.oneOrNone(cashInSql, [cashInTx.PENDING_INTERVAL, txId])
|
||||
} else {
|
||||
return db.oneOrNone(cashOutSql, [txId, REDEEMABLE_AGE])
|
||||
}
|
||||
return txClass === 'cashIn'
|
||||
? db.oneOrNone(cashInSql, [cashInTx.PENDING_INTERVAL, txId])
|
||||
: db.oneOrNone(cashOutSql, [txId, REDEEMABLE_AGE])
|
||||
}
|
||||
|
||||
function getTxAssociatedData (txId, txClass) {
|
||||
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`
|
||||
if (txClass === 'cashIn') {
|
||||
return db.manyOrNone(billsSql, [txId])
|
||||
} else {
|
||||
return db.manyOrNone(actionsSql, [txId])
|
||||
}
|
||||
|
||||
return txClass === 'cashIn'
|
||||
? db.manyOrNone(billsSql, [txId])
|
||||
: db.manyOrNone(actionsSql, [txId])
|
||||
}
|
||||
|
||||
module.exports = { batch, single, cancel, getCustomerTransactionsBatch, getTx, getTxAssociatedData }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue