From accd6d3e15d77857592458b2c9f21fd7661aa919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Oliveira?= Date: Wed, 24 Mar 2021 22:35:05 +0000 Subject: [PATCH] refactor: replace if else with ternary operators --- lib/new-admin/services/transactions.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/new-admin/services/transactions.js b/lib/new-admin/services/transactions.js index 88632ba0..a0670665 100644 --- a/lib/new-admin/services/transactions.js +++ b/lib/new-admin/services/transactions.js @@ -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 }