Skip to content

Commit

Permalink
feature(Feature Amounts): Undoes hack of setting legacy_import to pro…
Browse files Browse the repository at this point in the history
…ject for puvspr shapefile uploads
  • Loading branch information
KevSanchez committed Oct 25, 2023
1 parent 6205239 commit b57c969
Showing 1 changed file with 1 addition and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ import { chunk } from 'lodash';
import { Left } from 'fp-ts/lib/Either';
import { CHUNK_SIZE_FOR_BATCH_APIDB_OPERATIONS } from '@marxan-api/utils/chunk-size-for-batch-apidb-operations';
import { UploadedFeatureAmount } from '@marxan-api/modules/geo-features/import/features-amounts-data.api.entity';
import { Project } from '@marxan-api/modules/projects/project.api.entity';
import { ProjectSourcesEnum } from '@marxan/projects';
import { ScenariosService } from '@marxan-api/modules/scenarios/scenarios.service';

@Injectable()
export class FeatureAmountUploadService {
Expand Down Expand Up @@ -109,22 +106,13 @@ export class FeatureAmountUploadService {
this.logger.log(
`Upload temporary data removed from apiDB uploads tables`,
);
// Setting project source to legacy-import to create puvspr.dat files from pre-calculated amounts, to allow to use new features after upload
this.logger.log(`Updating project sources value to legacy-import...`);
await this.updateProjectSources(
data.projectId,
ProjectSourcesEnum.legacyImport,
apiQueryRunner.manager,
);

this.logger.log(`Saving min and max amounts for new features...`);

this.logger.log(`Csv file upload process finished successfully`);
// Committing transaction

await apiQueryRunner.commitTransaction();
await geoQueryRunner.commitTransaction();

this.logger.log(`Saving min and max amounts for new features...`);
await this.geoFeaturesService.saveAmountRangeForFeatures(
newFeaturesFromCsvUpload.map((feature) => feature.id),
);
Expand Down Expand Up @@ -401,17 +389,4 @@ export class FeatureAmountUploadService {

return { featureNames: Array.from(featureNames), puids: Array.from(puids) };
}

private async updateProjectSources(
projectId: string,
sources: ProjectSourcesEnum,
entityManager: EntityManager,
) {
await entityManager
.createQueryBuilder()
.update(Project)
.set({ sources })
.where('id = :projectId', { projectId })
.execute();
}
}

0 comments on commit b57c969

Please sign in to comment.