fix: simplify promise chain

This commit is contained in:
José Oliveira 2022-01-20 12:34:22 +00:00
parent 8fe9c2551a
commit a28d7d1aab
2 changed files with 3 additions and 5 deletions

View file

@ -88,7 +88,7 @@ function update (id, data, userToken, txId) {
' where id=$1 returning *'
return db.one(sql, [id])
.then(customerData => {
.then(customerData => {
return getEditedData(id)
.then(customerEditedData => selectLatestData(customerData, customerEditedData))
})

View file

@ -26,10 +26,8 @@ function addOrUpdateCustomer (req) {
return add(req.body)
})
.then(customer => {
return Promise.all([getEditedData(customer.id), getCustomerById(customer.id)])
.then(([customerEditedData, customerOriginalData]) => selectLatestData(customerOriginalData, customerEditedData))
})
.then(customer => Promise.all([getEditedData(customer.id), getCustomerById(customer.id)]))
.then(([customerEditedData, customerOriginalData]) => selectLatestData(customerOriginalData, customerEditedData))
.then(customer => {
// BACKWARDS_COMPATIBILITY 7.5
// machines before 7.5 expect customer with sanctions result