From 4dc4d14742e187513ad515e1765713927197acd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Mon, 1 Aug 2022 12:23:02 +0100 Subject: [PATCH 1/3] fix: export all transactions to CSV --- lib/new-admin/services/transactions.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/new-admin/services/transactions.js b/lib/new-admin/services/transactions.js index 733fcad9..58983305 100644 --- a/lib/new-admin/services/transactions.js +++ b/lib/new-admin/services/transactions.js @@ -51,6 +51,7 @@ function batch ( simplified ) { const packager = _.flow(_.flatten, _.orderBy(_.property('created'), ['desc']), _.map(camelize), addProfits, addNames) + const isCsvExport = _.isBoolean(simplified) const cashInSql = `SELECT 'cashIn' AS tx_class, txs.*, c.phone AS customer_phone, @@ -80,7 +81,7 @@ function batch ( AND ($12 is null or txs.to_address = $12) AND ($13 is null or txs.txStatus = $13) ${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``} - AND (error IS NOT null OR tb.error_message IS NOT null OR fiat > 0) + ${isCsvExport ? '' : 'AND (error IS NOT null OR tb.error_message IS NOT null OR fiat > 0)'} ORDER BY created DESC limit $4 offset $5` const cashOutSql = `SELECT 'cashOut' AS tx_class, @@ -114,7 +115,7 @@ function batch ( AND ($13 is null or txs.txStatus = $13) AND ($14 is null or txs.swept = $14) ${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``} - AND (fiat > 0) + ${isCsvExport ? '' : 'AND fiat > 0'} ORDER BY created DESC limit $4 offset $5` // The swept filter is cash-out only, so omit the cash-in query entirely From eed09b52ca75aa92471fa3da998b9d4aed84fe38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Tue, 2 Aug 2022 15:50:48 +0100 Subject: [PATCH 2/3] refactor: simplified CSV testing --- lib/new-admin/services/transactions.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/new-admin/services/transactions.js b/lib/new-admin/services/transactions.js index 58983305..5ecf5c05 100644 --- a/lib/new-admin/services/transactions.js +++ b/lib/new-admin/services/transactions.js @@ -141,14 +141,14 @@ function batch ( return Promise.all(promises) .then(packager) - .then(res => { - if (simplified) return simplifiedBatch(res) + .then(res => + !isCsvExport ? 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 - }) + simplified ? simplifiedBatch(res) : + advancedBatch(res) + ) } function advancedBatch (data) { From 753595e0df1729636ba721ac2426c068474c1b39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20S=C3=A1?= Date: Mon, 12 Sep 2022 16:37:47 +0100 Subject: [PATCH 3/3] fix: don't export empty transactions to simplified CSV --- lib/new-admin/services/transactions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/new-admin/services/transactions.js b/lib/new-admin/services/transactions.js index 5ecf5c05..439c0a3e 100644 --- a/lib/new-admin/services/transactions.js +++ b/lib/new-admin/services/transactions.js @@ -81,7 +81,7 @@ function batch ( AND ($12 is null or txs.to_address = $12) AND ($13 is null or txs.txStatus = $13) ${excludeTestingCustomers ? `AND c.is_test_customer is false` : ``} - ${isCsvExport ? '' : '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` const cashOutSql = `SELECT 'cashOut' AS tx_class,