From 17dc736b289b6d1e0c065dfff626a504573607ca Mon Sep 17 00:00:00 2001 From: andrea rota Date: Fri, 19 Apr 2024 19:57:43 +0100 Subject: [PATCH] add more detail to log output --- .../import/features-amounts-upload.service.ts | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/api/apps/api/src/modules/geo-features/import/features-amounts-upload.service.ts b/api/apps/api/src/modules/geo-features/import/features-amounts-upload.service.ts index b5cefd80a3..8bebca9f9a 100644 --- a/api/apps/api/src/modules/geo-features/import/features-amounts-upload.service.ts +++ b/api/apps/api/src/modules/geo-features/import/features-amounts-upload.service.ts @@ -164,7 +164,7 @@ export class FeatureAmountUploadService { await this.events.failEvent(data.projectId, err); this.logger.error( - 'An error occurred creating features and saving amounts from csv (changes have been rolled back)', + 'An error occurred while creating features and saving amounts from csv (changes have been rolled back)', String(err), ); throw err; @@ -241,7 +241,9 @@ export class FeatureAmountUploadService { userId, }); for (const [index, chunk] of featuresChunks.entries()) { - this.logger.log(`Inserting chunk ${index} to temporary table...`); + this.logger.log( + `Inserting chunk ${index}/${featuresChunks.length} to temporary table...`, + ); await entityManager .createQueryBuilder() .insert() @@ -249,7 +251,7 @@ export class FeatureAmountUploadService { .values(chunk.map((feature) => ({ ...feature, upload: newUpload }))) .execute(); } - this.logger.log(`New csv upload data from saved to temporary tables`); + this.logger.log(`Data from CSV file saved to temporary table`); return newUpload; } @@ -347,16 +349,16 @@ export class FeatureAmountUploadService { ); this.logger.log( - `Feature data divided into ${featuresChunks.length} chunks`, + `Feature data divided into ${featuresChunks.length} chunks`, ); for (const [amountIndex, featureChunk] of featuresChunks.entries()) { this.logger.log( - `Starting the process of saving chunk with index ${amountIndex} of amounts of feature ${newFeature.feature_class_name}...`, + `Starting to save chunk ${amountIndex}/${featuresChunks.length} of amounts of feature ${newFeature.feature_class_name}...`, ); const firstParameterNumber = 2; const parameters: any[] = [projectId]; this.logger.log( - `Generating values to insert for chunk with index ${amountIndex}...`, + `Generating values to insert for chunk ${amountIndex}/${featuresChunks.length}...`, ); const valuesToInsert = featureChunk.map((featureAmount, index) => { parameters.push( @@ -382,7 +384,7 @@ export class FeatureAmountUploadService { }); this.logger.log( - `Inserting amount values of chunk with index ${amountIndex} into (geoDB).features_data table...`, + `Inserting amounts of feature per planning unit of chunk ${amountIndex}/${featuresChunks.length} into (geoDB).features_data table...`, ); await geoQueryRunner.manager.query( ` @@ -403,14 +405,16 @@ export class FeatureAmountUploadService { [projectId, newFeature.id], ); this.logger.log( - `Chunk with index ${amountIndex} saved to (geoDB).features_data`, + `Chunk ${amountIndex}/${featuresChunks.length} saved to (geoDB).features_data`, ); } this.logger.log( `All chunks of feature ${newFeature.feature_class_name} saved`, ); } - this.logger.log(`All new features data saved to (geoDB).features_data`); + this.logger.log( + `Data for all new features was saved to (geoDB).features_data`, + ); } private async areFeatureNamesNotAlreadyUsedInProject(