Always add *_by_name fields along with *_by fields

This commit is contained in:
goga-m 2017-09-29 20:49:28 +03:00 committed by Josh Harvey
parent 84bc84e7c1
commit 2abed2ed57

View file

@ -187,14 +187,12 @@ function format (customer) {
*/ */
function populateOverrideUsernames (customer) { function populateOverrideUsernames (customer) {
return Promise.all(_.map(field => { return Promise.all(_.map(field => {
if (customer[field + '_override_by']) { return users.get(customer[field + '_override_by'])
return users.get(customer[field + '_override_by'])
.then(user => { .then(user => {
// just add the name to the customer object // just add the name to the customer object
customer[field + '_override_by_name'] = user.name customer[field + '_override_by_name'] = (user) ? user.name : null
return null return null
}) })
} else return null
}, getComplianceTypes())) }, getComplianceTypes()))
.then(() => customer) .then(() => customer)
} }