feat: correct timezone offset on downloaded logs
This commit is contained in:
parent
ac3dcef35a
commit
a0c77b4939
7 changed files with 74 additions and 16 deletions
|
|
@ -1,5 +1,7 @@
|
|||
const DataLoader = require('dataloader')
|
||||
const { parseAsync } = require('json2csv')
|
||||
const moment = require('moment')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const filters = require('../../filters')
|
||||
const transactions = require('../../services/transactions')
|
||||
|
|
@ -18,6 +20,15 @@ const txLogFields = ['txClass', 'id', 'deviceId', 'toAddress', 'cryptoAtoms',
|
|||
'customerIdCardDataExpiration', 'customerIdCardData', 'customerName',
|
||||
'customerFrontCameraPath', 'customerIdCardPhotoPath', 'expired', 'machineName']
|
||||
|
||||
const dateFormat = (timezone, logs) => _.map(log => {
|
||||
const offset = timezone.split(':')[1]
|
||||
return {
|
||||
...log,
|
||||
created: moment.utc(log.created).utcOffset(parseInt(offset)).format('YYYY-MM-DDTHH:mm:ss.SSS'),
|
||||
sendTime: moment.utc(log.sendTime).utcOffset(parseInt(offset)).format('YYYY-MM-DDTHH:mm:ss.SSS')
|
||||
}
|
||||
}, logs)
|
||||
|
||||
const resolvers = {
|
||||
Customer: {
|
||||
transactions: parent => transactionsLoader.load(parent.id)
|
||||
|
|
@ -30,11 +41,11 @@ const resolvers = {
|
|||
transactions.batch(from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status),
|
||||
transactionsCsv: (...[, { from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status }]) =>
|
||||
transactions.batch(from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status)
|
||||
.then(data => parseAsync(data, {fields: tx_logFields})),
|
||||
.then(data => parseAsync(data, { fields: tx_logFields, transforms: dateFormat(timezone, data) })),
|
||||
transactionCsv: (...[, { id, txClass }]) =>
|
||||
transactions.getTx(id, txClass).then(parseAsync),
|
||||
transactions.getTx(id, txClass).then(data => parseAsync(data)),
|
||||
txAssociatedDataCsv: (...[, { id, txClass }]) =>
|
||||
transactions.getTxAssociatedData(id, txClass).then(parseAsync),
|
||||
transactions.getTxAssociatedData(id, txClass).then(data => parseAsync(data)),
|
||||
transactionFilters: () => filters.transaction()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue