fix: issue with continuously building the csv
fix: added missing columns on downloaded logs
This commit is contained in:
parent
9abd8b2a88
commit
c5ba1b34b3
2 changed files with 31 additions and 15 deletions
|
|
@ -10,17 +10,6 @@ const anonymous = require('../../../constants').anonymousCustomer
|
||||||
const logDateFormat = require('../../../logs').logDateFormat
|
const logDateFormat = require('../../../logs').logDateFormat
|
||||||
|
|
||||||
const transactionsLoader = new DataLoader(ids => transactions.getCustomerTransactionsBatch(ids), { cache: false })
|
const transactionsLoader = new DataLoader(ids => transactions.getCustomerTransactionsBatch(ids), { cache: false })
|
||||||
const txLogFields = ['txClass', 'id', 'deviceId', 'toAddress', 'cryptoAtoms',
|
|
||||||
'cryptoCode', 'fiat', 'fiatCode', 'fee', 'status', 'fiatProfit',
|
|
||||||
'dispense', 'notified', 'redeem', 'phone', 'error',
|
|
||||||
'created', 'confirmedAt', 'hdIndex', 'swept', 'timedout',
|
|
||||||
'dispenseConfirmed', 'provisioned1', 'provisioned2',
|
|
||||||
'denomination1', 'denomination2', 'errorCode', 'customerId',
|
|
||||||
'txVersion', 'publishedAt', 'termsAccepted', 'layer2Address',
|
|
||||||
'commissionPercentage', 'rawTickerPrice', 'receivedCryptoAtoms',
|
|
||||||
'discount', 'txHash', 'customerPhone', 'customerIdCardDataNumber',
|
|
||||||
'customerIdCardDataExpiration', 'customerIdCardData', 'customerName',
|
|
||||||
'customerFrontCameraPath', 'customerIdCardPhotoPath', 'expired', 'machineName', 'walletScore']
|
|
||||||
|
|
||||||
const resolvers = {
|
const resolvers = {
|
||||||
Customer: {
|
Customer: {
|
||||||
|
|
@ -34,7 +23,7 @@ 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']), { fields: txLogFields })),
|
.then(data => parseAsync(logDateFormat(timezone, data, ['created', 'sendTime']))),
|
||||||
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']))
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ function batch (
|
||||||
toAddress = null,
|
toAddress = null,
|
||||||
status = null,
|
status = null,
|
||||||
excludeTestingCustomers = false,
|
excludeTestingCustomers = false,
|
||||||
simplified = false
|
simplified
|
||||||
) {
|
) {
|
||||||
const packager = _.flow(_.flatten, _.orderBy(_.property('created'), ['desc']), _.map(camelize), addProfits, addNames)
|
const packager = _.flow(_.flatten, _.orderBy(_.property('created'), ['desc']), _.map(camelize), addProfits, addNames)
|
||||||
|
|
||||||
|
|
@ -120,13 +120,40 @@ function batch (
|
||||||
.then(packager)
|
.then(packager)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (simplified) return simplifiedBatch(res)
|
if (simplified) return simplifiedBatch(res)
|
||||||
else return res
|
// GQL transactions and transactionsCsv both use this function and
|
||||||
|
// if we don't check for the correct simplified value, the Transactions page polling
|
||||||
|
// will continuously build a csv in the background
|
||||||
|
else if (simplified === false) return advancedBatch(res)
|
||||||
|
return res
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function advancedBatch (data) {
|
||||||
|
const fields = ['txClass', 'id', 'deviceId', 'toAddress', 'cryptoAtoms',
|
||||||
|
'cryptoCode', 'fiat', 'fiatCode', 'fee', 'status', 'fiatProfit', 'cryptoAmount',
|
||||||
|
'dispense', 'notified', 'redeem', 'phone', 'error',
|
||||||
|
'created', 'confirmedAt', 'hdIndex', 'swept', 'timedout',
|
||||||
|
'dispenseConfirmed', 'provisioned1', 'provisioned2',
|
||||||
|
'denomination1', 'denomination2', 'errorCode', 'customerId',
|
||||||
|
'txVersion', 'publishedAt', 'termsAccepted', 'layer2Address',
|
||||||
|
'commissionPercentage', 'rawTickerPrice', 'receivedCryptoAtoms',
|
||||||
|
'discount', 'txHash', 'customerPhone', 'customerIdCardDataNumber',
|
||||||
|
'customerIdCardDataExpiration', 'customerIdCardData', 'customerName',
|
||||||
|
'customerFrontCameraPath', 'customerIdCardPhotoPath', 'expired', 'machineName', 'walletScore']
|
||||||
|
|
||||||
|
const addAdvancedFields = _.map(it => ({
|
||||||
|
...it,
|
||||||
|
status: getStatus(it),
|
||||||
|
fiatProfit: getProfit(it).toString(),
|
||||||
|
cryptoAmount: getCryptoAmount(it).toString()
|
||||||
|
}))
|
||||||
|
|
||||||
|
return _.compose(_.map(_.pick(fields)), addAdvancedFields)(data)
|
||||||
|
}
|
||||||
|
|
||||||
function simplifiedBatch (data) {
|
function simplifiedBatch (data) {
|
||||||
const fields = ['txClass', 'id', 'created', 'machineName',
|
const fields = ['txClass', 'id', 'created', 'machineName',
|
||||||
'cryptoCode', 'fiat', 'fiatCode', 'phone', 'toAddress',
|
'cryptoCode', 'cryptoAtoms', 'fiat', 'fiatCode', 'phone', 'toAddress',
|
||||||
'txHash', 'dispense', 'error', 'status', 'fiatProfit', 'cryptoAmount']
|
'txHash', 'dispense', 'error', 'status', 'fiatProfit', 'cryptoAmount']
|
||||||
|
|
||||||
const addSimplifiedFields = _.map(it => ({
|
const addSimplifiedFields = _.map(it => ({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue