fix: move raw data parsing to machine
This commit is contained in:
parent
3d011ec079
commit
5d868af9e7
2 changed files with 2 additions and 16 deletions
|
|
@ -73,7 +73,7 @@ function update (id, data, userToken, txId) {
|
||||||
const formattedData = _.omit(['id'], _.mapKeys(_.snakeCase, data))
|
const formattedData = _.omit(['id'], _.mapKeys(_.snakeCase, data))
|
||||||
|
|
||||||
const enhancedUpdateData = enhanceAtFields(enhanceOverrideFields(formattedData, userToken))
|
const enhancedUpdateData = enhanceAtFields(enhanceOverrideFields(formattedData, userToken))
|
||||||
const updateData = updateRawData(updateOverride(enhancedUpdateData))
|
const updateData = updateOverride(enhancedUpdateData)
|
||||||
|
|
||||||
const sql = Pgp.helpers.update(updateData, _.keys(updateData), 'customers') +
|
const sql = Pgp.helpers.update(updateData, _.keys(updateData), 'customers') +
|
||||||
' where id=$1 returning *'
|
' where id=$1 returning *'
|
||||||
|
|
@ -281,20 +281,6 @@ function enhanceAtFields (fields) {
|
||||||
return _.merge(fields, atFields)
|
return _.merge(fields, atFields)
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateRawData (fields) {
|
|
||||||
const fieldsWithRawData = [
|
|
||||||
'id_card_data'
|
|
||||||
]
|
|
||||||
|
|
||||||
const fieldsToUpdate = _.intersection(fieldsWithRawData, _.keys(fields))
|
|
||||||
const rawFields = _.fromPairs(_.map(f => [`${f}_raw`, JSON.stringify(fields[f].raw)], fieldsToUpdate))
|
|
||||||
const fieldsWithoutRawData = _.mapValues(f => {
|
|
||||||
return _.has(f, 'raw') ? _.omit(['raw'], f) : f
|
|
||||||
}, fields)
|
|
||||||
|
|
||||||
return _.merge(fieldsWithoutRawData, rawFields)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add *override_by and *override_at fields with acting user's token
|
* Add *override_by and *override_at fields with acting user's token
|
||||||
* and date of override respectively before saving to db.
|
* and date of override respectively before saving to db.
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "lamassu-server",
|
"name": "lamassu-server",
|
||||||
"description": "bitcoin atm client server protocol module",
|
"description": "bitcoin atm client server protocol module",
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"version": "7.5.0-beta.1",
|
"version": "7.5.0-beta.2",
|
||||||
"license": "Unlicense",
|
"license": "Unlicense",
|
||||||
"author": "Lamassu (https://lamassu.is)",
|
"author": "Lamassu (https://lamassu.is)",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue