Skip to content

Commit

Permalink
add more detail to log output
Browse files Browse the repository at this point in the history
  • Loading branch information
hotzevzl committed Apr 23, 2024
1 parent ca001d6 commit 17dc736
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -241,15 +241,17 @@ 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()
.into(UploadedFeatureAmount)
.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;
}

Expand Down Expand Up @@ -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(
Expand All @@ -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(
`
Expand All @@ -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(
Expand Down

0 comments on commit 17dc736

Please sign in to comment.