diff --git a/api/apps/api/src/migrations/api/1708099064649-AddFeatureShapefileApiEvents.ts b/api/apps/api/src/migrations/api/1708099064649-AddFeatureShapefileApiEvents.ts index 8d96af5173..be17d3832b 100644 --- a/api/apps/api/src/migrations/api/1708099064649-AddFeatureShapefileApiEvents.ts +++ b/api/apps/api/src/migrations/api/1708099064649-AddFeatureShapefileApiEvents.ts @@ -24,9 +24,8 @@ export class AddFeatureShapefileApiEvents1708099064649 'features.shapefile.import.finished/v1/alpha', 'features.shapefile.import.failed/v1/alpha') `); - await queryRunner.query(` - UPDATE features SET creation_status = 'done' - WHERE creation_status = 'created'; - `); + + // While creation_status mostly didn't have any real use so far, the 'created'->'done' migration is a non reversible operation + // as there's no way which creation_status any row had originally. } } diff --git a/api/apps/api/src/modules/analysis/providers/shared/__mocks__/scenario-planning-unit-geo.data.ts b/api/apps/api/src/modules/analysis/providers/shared/__mocks__/scenario-planning-unit-geo.data.ts index 2b31b8ac11..ab8e4dfe96 100644 --- a/api/apps/api/src/modules/analysis/providers/shared/__mocks__/scenario-planning-unit-geo.data.ts +++ b/api/apps/api/src/modules/analysis/providers/shared/__mocks__/scenario-planning-unit-geo.data.ts @@ -16,5 +16,4 @@ export const validDataWithGivenPuIds = ( projectPuId: v4(), id: id, featureList: [], - setByUser: false, })); diff --git a/api/apps/api/src/modules/geo-features/geo-features.service.ts b/api/apps/api/src/modules/geo-features/geo-features.service.ts index cb1fe903e5..7a3739fd26 100644 --- a/api/apps/api/src/modules/geo-features/geo-features.service.ts +++ b/api/apps/api/src/modules/geo-features/geo-features.service.ts @@ -458,11 +458,13 @@ export class GeoFeaturesService extends AppBaseService< data: UploadShapefileDTO, featureDatas: Record[], ) { - try { - setTimeout(async () => { + setTimeout(async () => { + try { await this.createFeaturesForShapefile(projectId, data, featureDatas); - }); - } catch (e) {} + } catch (e) { + this.logger.error(e.message, e.trace); + } + }); } public async createFeaturesForShapefile( @@ -991,7 +993,7 @@ export class GeoFeaturesService extends AppBaseService< return left(featureDataCannotBeUploadedWithCsv); } - this.featureAmountUploads.uploadFeatureFromCSVAsync( + await this.featureAmountUploads.uploadFeatureFromCSVAsync( fileBuffer, projectId, userId, diff --git a/api/apps/geoprocessing/test/integration/cloning/fixtures.ts b/api/apps/geoprocessing/test/integration/cloning/fixtures.ts index e20c7b428a..22564edbf6 100644 --- a/api/apps/geoprocessing/test/integration/cloning/fixtures.ts +++ b/api/apps/geoprocessing/test/integration/cloning/fixtures.ts @@ -117,6 +117,7 @@ export async function GivenProjectExists( organizationId: string, projectData: Record = {}, costSurfaceId = v4(), + costSurfaceStableId = v4(), ) { await GivenOrganizationExists(em, organizationId); @@ -133,7 +134,13 @@ export async function GivenProjectExists( }) .execute(); - await GivenDefaultCostSurfaceForProject(em, projectId, costSurfaceId); + await GivenDefaultCostSurfaceForProject( + em, + projectId, + costSurfaceId, + undefined, + costSurfaceStableId, + ); return insertResult; } @@ -150,6 +157,7 @@ async function GivenDefaultCostSurfaceForProject( projectId: string, id: string, name?: string, + costSurfaceStableId = v4(), ) { const nameForCostSurface = name || projectId; return em @@ -165,6 +173,7 @@ async function GivenDefaultCostSurfaceForProject( min: 0, max: 0, is_default: true, + stable_id: costSurfaceStableId, }) .execute(); } @@ -177,6 +186,7 @@ export async function GivenScenarioExists( scenarioData: Record = {}, projectData: Record = {}, costSurfaceId = v4(), + costSurfaceStableId = v4(), ) { await GivenProjectExists( em, @@ -184,6 +194,7 @@ export async function GivenScenarioExists( organizationId, projectData, costSurfaceId, + costSurfaceStableId, ); return em diff --git a/api/apps/geoprocessing/test/integration/cloning/piece-exporters/scenario-metadata.piece-exporter.e2e-spec.ts b/api/apps/geoprocessing/test/integration/cloning/piece-exporters/scenario-metadata.piece-exporter.e2e-spec.ts index 27656dadcd..285077d68a 100644 --- a/api/apps/geoprocessing/test/integration/cloning/piece-exporters/scenario-metadata.piece-exporter.e2e-spec.ts +++ b/api/apps/geoprocessing/test/integration/cloning/piece-exporters/scenario-metadata.piece-exporter.e2e-spec.ts @@ -84,6 +84,7 @@ const getFixtures = async () => { const projectId = v4(); const scenarioId = v4(); const costSurfaceId = v4(); + const costSurfaceStableId = v4(); const organizationId = v4(); const sut = sandbox.get(ScenarioMetadataPieceExporter); const apiEntityManager: EntityManager = sandbox.get( @@ -106,7 +107,7 @@ const getFixtures = async () => { ranAtLeastOnce: false, solutionsAreLocked, type: 'marxan', - cost_surface_id: costSurfaceId, + cost_surface_id: costSurfaceStableId, }); return { @@ -144,6 +145,7 @@ const getFixtures = async () => { }, {}, costSurfaceId, + costSurfaceStableId, ); }, GivenScenarioBlmRangeExist: async () => { diff --git a/api/apps/geoprocessing/test/steps/given-scenario-pu-data-exists.ts b/api/apps/geoprocessing/test/steps/given-scenario-pu-data-exists.ts index 91f006b530..33e76bce68 100644 --- a/api/apps/geoprocessing/test/steps/given-scenario-pu-data-exists.ts +++ b/api/apps/geoprocessing/test/steps/given-scenario-pu-data-exists.ts @@ -82,7 +82,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: first.id, projectPu: first, protectedByDefault, - setByUser: false, + lockStatusSetByUser: false, }, { scenarioId, @@ -90,7 +90,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: first.id, projectPu: first, protectedByDefault, - setByUser: false, + lockStatusSetByUser: false, }, { scenarioId, @@ -98,7 +98,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: first.id, projectPu: first, protectedByDefault, - setByUser: true, + lockStatusSetByUser: true, }, { scenarioId, @@ -106,7 +106,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: first.id, projectPu: first, protectedByDefault, - setByUser: true, + lockStatusSetByUser: true, }, { scenarioId, @@ -114,7 +114,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: first.id, projectPu: first, protectedByDefault, - setByUser: true, + lockStatusSetByUser: true, }, { scenarioId, @@ -122,7 +122,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: second.id, projectPu: second, protectedByDefault, - setByUser: true, + lockStatusSetByUser: true, }, { scenarioId, @@ -130,7 +130,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: second.id, projectPu: second, protectedByDefault, - setByUser: false, + lockStatusSetByUser: false, }, { scenarioId, @@ -138,7 +138,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: third.id, projectPu: third, protectedByDefault, - setByUser: true, + lockStatusSetByUser: true, }, { scenarioId, @@ -146,7 +146,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: third.id, projectPu: third, protectedByDefault, - setByUser: false, + lockStatusSetByUser: false, }, { scenarioId, @@ -154,7 +154,7 @@ export const GivenScenarioPuDataWithStatusesSetByUserExists = async ( projectPuId: third.id, projectPu: third, protectedByDefault, - setByUser: false, + lockStatusSetByUser: false, }, ]); return rows as ScenariosPuPaDataGeo[];