Merge pull request #1742 from RafaelTaranto/backport/csv-empty-txs

LAM-562 csv empty txs
This commit is contained in:
Rafael Taranto 2024-11-29 13:47:53 +00:00 committed by GitHub
commit affb98588a

View file

@ -50,6 +50,7 @@ function batch (
excludeTestingCustomers = false, excludeTestingCustomers = false,
simplified simplified
) { ) {
const isCsvExport = _.isBoolean(simplified)
const packager = _.flow( const packager = _.flow(
_.flatten, _.flatten,
_.orderBy(_.property('created'), ['desc']), _.orderBy(_.property('created'), ['desc']),
@ -92,7 +93,7 @@ function batch (
AND ($12 is null or txs.to_address = $12) AND ($12 is null or txs.to_address = $12)
AND ($13 is null or txs.txStatus = $13) AND ($13 is null or txs.txStatus = $13)
${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``} ${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``}
AND (error IS NOT null OR tb.error_message IS NOT null OR fiat > 0) ${isCsvExport && !simplified ? '' : 'AND (error IS NOT null OR tb.error_message IS NOT null OR fiat > 0)'}
ORDER BY created DESC limit $4 offset $5` ORDER BY created DESC limit $4 offset $5`
const cashOutSql = `SELECT 'cashOut' AS tx_class, const cashOutSql = `SELECT 'cashOut' AS tx_class,
@ -126,7 +127,7 @@ function batch (
AND ($13 is null or txs.txStatus = $13) AND ($13 is null or txs.txStatus = $13)
AND ($14 is null or txs.swept = $14) AND ($14 is null or txs.swept = $14)
${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``} ${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``}
AND (fiat > 0) ${isCsvExport ? '' : 'AND fiat > 0'}
ORDER BY created DESC limit $4 offset $5` ORDER BY created DESC limit $4 offset $5`
// The swept filter is cash-out only, so omit the cash-in query entirely // The swept filter is cash-out only, so omit the cash-in query entirely
@ -152,14 +153,14 @@ function batch (
return Promise.all(promises) return Promise.all(promises)
.then(packager) .then(packager)
.then(res => { .then(res =>
if (simplified) return simplifiedBatch(res) !isCsvExport ? res :
// GQL transactions and transactionsCsv both use this function and // GQL transactions and transactionsCsv both use this function and
// if we don't check for the correct simplified value, the Transactions page polling // if we don't check for the correct simplified value, the Transactions page polling
// will continuously build a csv in the background // will continuously build a csv in the background
else if (simplified === false) return advancedBatch(res) simplified ? simplifiedBatch(res) :
return res advancedBatch(res)
}) )
} }
function advancedBatch (data) { function advancedBatch (data) {