Skip to content

Commit

Permalink
fix(CostSurface): Changes name of default Cost Surface to be more des…
Browse files Browse the repository at this point in the history
…criptive
  • Loading branch information
KevSanchez committed Jan 23, 2024
1 parent b25b8c3 commit 0c20c31
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions api/apps/api/src/modules/cost-surface/cost-surface.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -62,7 +64,7 @@ export class CostSurfaceService {

createDefaultCostSurfaceModel(): CostSurface {
return this.costSurfaceRepository.create({
name: 'default',
name: costSurfaceDefaultName,
min: 1,
max: 1,
isDefault: true,
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
{
Expand Down Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions data/scripts/cost-surface/cost-surface-data-migration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import psycopg2


dry_run = True

# Connect to Database 1
Expand Down Expand Up @@ -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,))
Expand Down

1 comment on commit 0c20c31

@vercel
Copy link

@vercel vercel bot commented on 0c20c31 Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

marxan – ./

marxan-git-develop-vizzuality1.vercel.app
marxan23.vercel.app
marxan-vizzuality1.vercel.app

Please sign in to comment.