From 15e35a085521c935a987cb952524a7326b42cb35 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 21 Feb 2023 14:05:46 +0200 Subject: [PATCH 1/3] Return user _id to have same data structure as in framework mode --- workers/loc.api/service.report.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/workers/loc.api/service.report.js b/workers/loc.api/service.report.js index cb7f4aba..0dbf360c 100644 --- a/workers/loc.api/service.report.js +++ b/workers/loc.api/service.report.js @@ -157,7 +157,8 @@ class ReportService extends Api { timezone, email, id, - isSubAccount: false + isSubAccount: false, + _id: null // to have the same data structure as in framework mode } }, 'verifyUser', args, cb) } From 12637c0def23a1d33088368bf8e10f12d949a4c5 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 21 Feb 2023 14:09:56 +0200 Subject: [PATCH 2/3] Pass user info with csv aggregator completed event --- workers/loc.api/queue/aggregator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workers/loc.api/queue/aggregator.js b/workers/loc.api/queue/aggregator.js index a53122b8..1f401487 100644 --- a/workers/loc.api/queue/aggregator.js +++ b/workers/loc.api/queue/aggregator.js @@ -93,7 +93,7 @@ module.exports = ( } job.done() - aggregatorQueue.emit('completed', { newFilePaths }) + aggregatorQueue.emit('completed', { newFilePaths, userInfo }) } catch (err) { if (err.syscall === 'unlink') { aggregatorQueue.emit('error:unlink', job) From 9f26b3adf9f9d57bf93350af7cb74fc0876498e2 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 21 Feb 2023 15:15:01 +0200 Subject: [PATCH 3/3] Pass csv files metadata with aggregator completed event --- workers/loc.api/queue/aggregator.js | 40 +++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/workers/loc.api/queue/aggregator.js b/workers/loc.api/queue/aggregator.js index 1f401487..870686fd 100644 --- a/workers/loc.api/queue/aggregator.js +++ b/workers/loc.api/queue/aggregator.js @@ -38,6 +38,9 @@ module.exports = ( await hasGrcService.hasS3AndSendgrid() ) + const newFilePaths = [] + const csvFilesMetadata = [] + if (isEnableToSendEmail) { const s3Data = await uploadToS3( s3Conf, @@ -62,38 +65,55 @@ module.exports = ( })) ) - for (const filePath of filePaths) { + for (const [i, filePath] of filePaths.entries()) { + const _name = subParamsArr[i]?.name ?? name + await unlink(filePath) + + csvFilesMetadata.push({ + name: _name, + filePath: null + }) } job.done() - aggregatorQueue.emit('completed') + aggregatorQueue.emit('completed', { + newFilePaths, + csvFilesMetadata, + userInfo + }) return } - const newFilePaths = [] - let count = 0 + for (const [i, filePath] of filePaths.entries()) { + const _name = subParamsArr[i]?.name ?? name - for (const filePath of filePaths) { const { newFilePath } = await moveFileToLocalStorage( rootPath, filePath, - subParamsArr[count].name || name, - { ...subParamsArr[count] }, + _name, + { ...subParamsArr[i] }, userInfo.username, isAddedUniqueEndingToCsvName, - chunkCommonFolders[count] + chunkCommonFolders[i] ) newFilePaths.push(newFilePath) - count += 1 + csvFilesMetadata.push({ + name: _name, + filePath: newFilePath + }) } job.done() - aggregatorQueue.emit('completed', { newFilePaths, userInfo }) + aggregatorQueue.emit('completed', { + newFilePaths, + csvFilesMetadata, + userInfo + }) } catch (err) { if (err.syscall === 'unlink') { aggregatorQueue.emit('error:unlink', job)