From 0c20c31acc50cd49f7e6997c3fc825a57c270a84 Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 23 Jan 2024 15:30:58 +0100 Subject: [PATCH] fix(CostSurface): Changes name of default Cost Surface to be more descriptive --- .../api/src/modules/cost-surface/cost-surface.service.ts | 6 ++++-- .../projects/cost-surfaces/project-cost-surface.fixtures.ts | 5 +++-- data/scripts/cost-surface/cost-surface-data-migration.py | 3 +-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/apps/api/src/modules/cost-surface/cost-surface.service.ts b/api/apps/api/src/modules/cost-surface/cost-surface.service.ts index a1a21704b3..4867d01ddd 100644 --- a/api/apps/api/src/modules/cost-surface/cost-surface.service.ts +++ b/api/apps/api/src/modules/cost-surface/cost-surface.service.ts @@ -42,6 +42,8 @@ export const cannotDeleteDefaultCostSurface = Symbol( `cannot delete default cost surface`, ); +export const costSurfaceDefaultName = 'Cost Surface - default'; + export interface CostRange { min: number; max: number; @@ -62,7 +64,7 @@ export class CostSurfaceService { createDefaultCostSurfaceModel(): CostSurface { return this.costSurfaceRepository.create({ - name: 'default', + name: costSurfaceDefaultName, min: 1, max: 1, isDefault: true, @@ -107,7 +109,7 @@ export class CostSurfaceService { const min = 1; const max = 10; const instance = this.costSurfaceRepository.create({ - name: costSurfaceDto?.name ?? 'default', + name: costSurfaceDto?.name ?? costSurfaceDefaultName, projectId, min, max, diff --git a/api/apps/api/test/projects/cost-surfaces/project-cost-surface.fixtures.ts b/api/apps/api/test/projects/cost-surfaces/project-cost-surface.fixtures.ts index 3a74bec26c..9755e6346f 100644 --- a/api/apps/api/test/projects/cost-surfaces/project-cost-surface.fixtures.ts +++ b/api/apps/api/test/projects/cost-surfaces/project-cost-surface.fixtures.ts @@ -40,6 +40,7 @@ import { API_EVENT_KINDS } from '@marxan/api-events'; import { ScenarioRoles } from '@marxan-api/modules/access-control/scenarios-acl/dto/user-role-scenario.dto'; import { UsersScenariosApiEntity } from '@marxan-api/modules/access-control/scenarios-acl/entity/users-scenarios.api.entity'; import { ApiEvent } from '@marxan-api/modules/api-events/api-event.api.entity'; +import { costSurfaceDefaultName } from '@marxan-api/modules/cost-surface/cost-surface.service'; export const getProjectCostSurfaceFixtures = async () => { const app = await bootstrapApplication( @@ -106,7 +107,7 @@ export const getProjectCostSurfaceFixtures = async () => { }, GivenProject: async (projectName: string, roles?: ProjectRoles[]) => { - const { projectId, cleanup } = await GivenProjectExists( + const { projectId } = await GivenProjectExists( app, token, { @@ -478,7 +479,7 @@ export const getProjectCostSurfaceFixtures = async () => { }, ThenADefaultCostSurfaceWasCreated: async (projectId: string) => { const costSurface = await costSurfaceRepo.findOne({ - where: { projectId, name: 'default', isDefault: true }, + where: { projectId, name: costSurfaceDefaultName, isDefault: true }, }); expect(costSurface).toBeDefined(); diff --git a/data/scripts/cost-surface/cost-surface-data-migration.py b/data/scripts/cost-surface/cost-surface-data-migration.py index 0a049b5b15..05881cd321 100644 --- a/data/scripts/cost-surface/cost-surface-data-migration.py +++ b/data/scripts/cost-surface/cost-surface-data-migration.py @@ -1,6 +1,5 @@ import psycopg2 - dry_run = True # Connect to Database 1 @@ -68,7 +67,7 @@ # Insert new row in cost_surfaces with project-specific information insert_cost_surface_for_project_sql = ''' INSERT INTO cost_surfaces (id, project_id, min, max, is_default, name, is_migrated) - VALUES (gen_random_uuid(), %s, 1, 1, true, 'default', true); + VALUES (gen_random_uuid(), %s, 1, 1, true, 'Cost Surface - default', true); ''' cur_api_db.execute(insert_cost_surface_for_project_sql, (project_id,))