fix: check for date validity before conversion
This commit is contained in:
parent
2d5cbe771a
commit
2a85bfce2b
3 changed files with 9 additions and 4 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
const _ = require('lodash/fp')
|
const _ = require('lodash/fp')
|
||||||
const { format } = require('date-fns/fp')
|
const { format, isValid } = require('date-fns/fp')
|
||||||
const { utcToZonedTime } = require('date-fns-tz/fp')
|
const { utcToZonedTime } = require('date-fns-tz/fp')
|
||||||
|
|
||||||
const db = require('./db')
|
const db = require('./db')
|
||||||
|
const logger = require('./logger')
|
||||||
const pgp = require('pg-promise')()
|
const pgp = require('pg-promise')()
|
||||||
|
|
||||||
const getMachineName = require('./machine-loader').getMachineName
|
const getMachineName = require('./machine-loader').getMachineName
|
||||||
|
|
@ -118,6 +119,10 @@ function logDateFormat (timezone, logs, fields) {
|
||||||
field =>
|
field =>
|
||||||
{
|
{
|
||||||
if (_.isNil(log[field])) return null
|
if (_.isNil(log[field])) return null
|
||||||
|
if (!isValid(log[field])) {
|
||||||
|
logger.warn(`Tried to convert to ${timezone} timezone the value ${log[field]} and failed. Returning original value...`)
|
||||||
|
return log[field]
|
||||||
|
}
|
||||||
const date = utcToZonedTime(timezone, log[field])
|
const date = utcToZonedTime(timezone, log[field])
|
||||||
return `${format('yyyy-MM-dd', date)}T${format('HH:mm:ss.SSS', date)}`
|
return `${format('yyyy-MM-dd', date)}T${format('HH:mm:ss.SSS', date)}`
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ const resolvers = {
|
||||||
transactions.batch(from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, excludeTestingCustomers),
|
transactions.batch(from, until, limit, offset, deviceId, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, excludeTestingCustomers),
|
||||||
transactionsCsv: (...[, { from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, timezone, excludeTestingCustomers, simplified }]) =>
|
transactionsCsv: (...[, { from, until, limit, offset, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, timezone, excludeTestingCustomers, simplified }]) =>
|
||||||
transactions.batch(from, until, limit, offset, null, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, excludeTestingCustomers, simplified)
|
transactions.batch(from, until, limit, offset, null, txClass, machineName, customerName, fiatCode, cryptoCode, toAddress, status, excludeTestingCustomers, simplified)
|
||||||
.then(data => parseAsync(logDateFormat(timezone, data, ['created', 'sendTime']))),
|
.then(data => parseAsync(logDateFormat(timezone, data, ['created', 'sendTime', 'publishedAt']))),
|
||||||
transactionCsv: (...[, { id, txClass, timezone }]) =>
|
transactionCsv: (...[, { id, txClass, timezone }]) =>
|
||||||
transactions.getTx(id, txClass).then(data =>
|
transactions.getTx(id, txClass).then(data =>
|
||||||
parseAsync(logDateFormat(timezone, [data], ['created', 'sendTime']))
|
parseAsync(logDateFormat(timezone, [data], ['created', 'sendTime', 'publishedAt']))
|
||||||
),
|
),
|
||||||
txAssociatedDataCsv: (...[, { id, txClass, timezone }]) =>
|
txAssociatedDataCsv: (...[, { id, txClass, timezone }]) =>
|
||||||
transactions.getTxAssociatedData(id, txClass).then(data =>
|
transactions.getTxAssociatedData(id, txClass).then(data =>
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ function advancedBatch (data) {
|
||||||
'txVersion', 'publishedAt', 'termsAccepted', 'layer2Address',
|
'txVersion', 'publishedAt', 'termsAccepted', 'layer2Address',
|
||||||
'commissionPercentage', 'rawTickerPrice', 'receivedCryptoAtoms',
|
'commissionPercentage', 'rawTickerPrice', 'receivedCryptoAtoms',
|
||||||
'discount', 'txHash', 'customerPhone', 'customerIdCardDataNumber',
|
'discount', 'txHash', 'customerPhone', 'customerIdCardDataNumber',
|
||||||
'customerIdCardDataExpiration', 'customerIdCardData', 'customerName',
|
'customerIdCardDataExpiration', 'customerIdCardData', 'customerName', 'sendTime',
|
||||||
'customerFrontCameraPath', 'customerIdCardPhotoPath', 'expired', 'machineName', 'walletScore']
|
'customerFrontCameraPath', 'customerIdCardPhotoPath', 'expired', 'machineName', 'walletScore']
|
||||||
|
|
||||||
const addAdvancedFields = _.map(it => ({
|
const addAdvancedFields = _.map(it => ({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue