Skip to content

Commit

Permalink
only insert into fappu table once all the features_data rows have bee…
Browse files Browse the repository at this point in the history
…n created, to avoid inserting duplicates [MRXN23-609]
  • Loading branch information
hotzevzl committed Apr 23, 2024
1 parent 17dc736 commit eaf7a07
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -398,19 +398,20 @@ export class FeatureAmountUploadService {
`,
parameters,
);
await geoQueryRunner.manager.query(
` INSERT INTO feature_amounts_per_planning_unit (project_id, feature_id, amount, project_pu_id)
SELECT $1, $2, amount, project_pu_id
FROM features_data where feature_id = $2`,
[projectId, newFeature.id],
);
this.logger.log(
`Chunk ${amountIndex}/${featuresChunks.length} saved to (geoDB).features_data`,
);
}
this.logger.log(
`All chunks of feature ${newFeature.feature_class_name} saved`,
);

await geoQueryRunner.manager.query(
`INSERT INTO feature_amounts_per_planning_unit (project_id, feature_id, amount, project_pu_id)
SELECT $1, $2, amount, project_pu_id
FROM features_data where feature_id = $2`,
[projectId, newFeature.id],
);
}
this.logger.log(
`Data for all new features was saved to (geoDB).features_data`,
Expand Down

0 comments on commit eaf7a07

Please sign in to comment.