Add status field in customers.batch

This commit is contained in:
goga-m 2017-09-21 13:15:05 +03:00 committed by Josh Harvey
parent 0f5dfaa513
commit e347ddc608
2 changed files with 45 additions and 21 deletions

View file

@ -39,11 +39,30 @@ function getDailyVolume (id) {
})
}
/**
* Query all customers
*
* Add status as computed column,
* which will indicate the name of the latest
* compliance verfication completed by user.
*
* @returns {array} Array of customers populated with status field
*/
function batch () {
const sql = `select * from customers
const sql = `select
CASE GREATEST(
phone_at,
id_card_at,
front_facing_cam_at,
id_card_image_at
)
WHEN phone_at THEN 'Phone'
WHEN id_card_at THEN 'ID card'
WHEN front_facing_cam_at THEN 'Front facing camera'
WHEN id_card_image_at THEN 'ID card image'
END AS status, * from customers
where id != $1
order by created desc limit $2`
return db.any(sql, [ anonymous.uuid, NUM_RESULTS ])
}
module.exports = { add, get, batch, getById }

File diff suppressed because one or more lines are too long