From 9ea6f090a3986a7605ec8161e18cc667bf52b2b0 Mon Sep 17 00:00:00 2001 From: Stefano Ricci Date: Thu, 19 Dec 2024 23:05:49 +0100 Subject: [PATCH] fixed error exporting filtered data in CSV including files --- .../service/DataExportJob/jobs/FilesExportJob.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/modules/dataExport/service/DataExportJob/jobs/FilesExportJob.js b/server/modules/dataExport/service/DataExportJob/jobs/FilesExportJob.js index f08582d244..8586083efb 100644 --- a/server/modules/dataExport/service/DataExportJob/jobs/FilesExportJob.js +++ b/server/modules/dataExport/service/DataExportJob/jobs/FilesExportJob.js @@ -1,3 +1,5 @@ +import { Objects } from '@openforis/arena-core' + import * as Survey from '@core/survey/survey' import Job from '@server/job/job' @@ -14,7 +16,7 @@ export default class FilesExportJob extends Job { } async execute() { - const { survey, cycle, includeDataFromAllCycles, recordUuids } = this.context + const { survey, cycle, fileNamesByFileUuid, includeDataFromAllCycles, recordUuids } = this.context const { fileUuidsByCycle, total } = await SurveyRdbService.fetchEntitiesFileUuidsByCycle( { @@ -31,7 +33,10 @@ export default class FilesExportJob extends Job { // write the files in subfolders by cycle for await (const [cycle, fileUuids] of Object.entries(fileUuidsByCycle)) { for await (const fileUuid of fileUuids) { - await this.writeFile({ fileUuid, cycle }) + const exportedFileName = fileNamesByFileUuid[fileUuid] + if (Objects.isNotEmpty(exportedFileName)) { + await this.writeFile({ fileUuid, cycle }) + } this.incrementProcessedItems() } }