From 53a8ebd0c047bceb356758ca932083dfc0bc0fa0 Mon Sep 17 00:00:00 2001 From: Shams mosowi Date: Mon, 22 Jun 2020 13:27:08 +0800 Subject: [PATCH] added delay between export csv chunk files --- www/.bashrc | 1 + www/src/components/Table/ExportCSV.tsx | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 www/.bashrc diff --git a/www/.bashrc b/www/.bashrc new file mode 100644 index 00000000..06e9748e --- /dev/null +++ b/www/.bashrc @@ -0,0 +1 @@ +export NODE_OPTIONS=--max_old_space_size=4096 \ No newline at end of file diff --git a/www/src/components/Table/ExportCSV.tsx b/www/src/components/Table/ExportCSV.tsx index bf1e4d1e..7dfa335f 100644 --- a/www/src/components/Table/ExportCSV.tsx +++ b/www/src/components/Table/ExportCSV.tsx @@ -21,7 +21,11 @@ import { SnackContext } from "contexts/snackContext"; import { useFiretableContext } from "contexts/firetableContext"; import { db } from "../../firebase"; import { FieldType } from "constants/fields"; - +async function asyncForEach(array, callback) { + for (let index = 0; index < array.length; index++) { + await callback(array[index], index, array); + } +} const ITEM_HEIGHT = 48; const ITEM_PADDING_TOP = 8; const MenuProps = { @@ -181,10 +185,13 @@ export default function ExportCSV() { return all; }, []); console.log(docChunks.length); - - docChunks.forEach((element, index) => { + await asyncForEach(docChunks, async (element, index) => { + await setTimeout(() => { + console.log(`saving part${index + 1}`); + }, 3000); saveDocs2CSV(element, index, docChunks.length); }); + // generate csv Data } const saveDocs2CSV = (docs, index, chunksLength) => {