Skip to content

Commit

Permalink
ref: remove feature set column form scenarios (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
aciddaute authored May 4, 2022
1 parent 5b1bb38 commit 6de238d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class RemoveFeatureSetFromScenarios1651666472019
implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`
ALTER TABLE scenarios
DROP COLUMN feature_set;
`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`
ALTER TABLE scenarios
ADD COLUMN feature_set jsonb;
`,
);
}
}
5 changes: 0 additions & 5 deletions api/apps/api/src/modules/scenarios/scenario.api.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
OneToOne,
PrimaryGeneratedColumn,
} from 'typeorm';
import { IUCNCategory } from '@marxan/iucn';
import { User } from '../users/user.api.entity';
import { IsArray, IsOptional } from 'class-validator';
import { TimeUserEntityMetadata } from '../../types/time-user-entity-metadata';
Expand Down Expand Up @@ -117,10 +116,6 @@ export class Scenario extends TimeUserEntityMetadata {
@IsOptional()
wdpaThreshold?: number | null;

@Column('jsonb', { name: 'feature_set' })
@IsOptional()
featureSet?: GeoFeatureSetSpecification;

/**
* Number of runs for Marxan calculations.
*/
Expand Down
32 changes: 0 additions & 32 deletions api/apps/api/src/modules/scenarios/scenarios.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -883,38 +883,6 @@ export class ScenariosService {
return !(await this.givenScenarioExists(scenarioId));
}

/**
* Get geofeatures specification for a scenario. This is part of the scenario
* itself, but exposed via a separate endpoint.
*/
async getFeatureSetForScenario(
scenarioId: string,
userInfo: AppInfoDTO,
): Promise<
| GeoFeatureSetSpecification
| typeof forbiddenError
| typeof scenarioNotFound
| undefined
> {
const scenarioResult = await this.getById(scenarioId, userInfo);
if (isLeft(scenarioResult)) return scenarioNotFound;

return await this.crudService
.getById(scenarioId)
.then((result) => {
return result.featureSet;
})
.then((result) =>
result
? this.geoFeaturePropertySetService.extendGeoFeatureProcessingSpecification(
result,
scenarioResult.right,
)
: EmptyGeoFeaturesSpecification,
)
.catch((e) => Logger.error(e));
}

async getMarxanExecutionOutputArchive(
scenarioId: string,
userId: string,
Expand Down

0 comments on commit 6de238d

Please sign in to comment.