Skip to content

Commit

Permalink
Fix api formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yulia-bel committed Sep 26, 2023
1 parent aaf11e9 commit a7730dc
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddClonePieceForProjectCostSurfaces1695040870835 implements MigrationInterface {

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TYPE clone_piece_enum ADD VALUE 'project-cost-surfaces'`,
);
}
export class AddClonePieceForProjectCostSurfaces1695040870835
implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TYPE clone_piece_enum ADD VALUE 'project-cost-surfaces'`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
CREATE TYPE "clone_piece_enum_tmp" AS ENUM(
'export-config',
'project-metadata',
Expand All @@ -33,21 +33,20 @@ export class AddClonePieceForProjectCostSurfaces1695040870835 implements Migrati
);
`);

await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE export_components
ALTER COLUMN piece TYPE clone_piece_enum_tmp;
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TABLE import_components
ALTER COLUMN piece TYPE clone_piece_enum_tmp;
`);

await queryRunner.query(`
await queryRunner.query(`
DROP TYPE clone_piece_enum;
`);
await queryRunner.query(`
await queryRunner.query(`
ALTER TYPE clone_piece_enum_tmp RENAME TO clone_piece_enum;
`);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class SelectionGetService {

return [
...categories.map((category) => ({
name: 'IUCN '+ category,
name: 'IUCN ' + category,
id: category,
isCustom: false,
})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ import { ScenarioOutputFolderPieceExporter } from './scenario-output-folder.piec
import { ScenarioPlanningUnitsDataPieceExporter } from './scenario-planning-units-data.piece-exporter';
import { ScenarioProtectedAreasPieceExporter } from './scenario-protected-areas.piece-exporter';
import { ScenarioRunResultsPieceExporter } from './scenario-run-results.piece-exporter';
import {
ProjectCostSurfacesPieceExporter
} from "@marxan-geoprocessing/export/pieces-exporters/project-cost-surfaces.piece-exporter";
import { ProjectCostSurfacesPieceExporter } from '@marxan-geoprocessing/export/pieces-exporters/project-cost-surfaces.piece-exporter';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ export class ProjectCostSurfacesPieceExporter implements ExportPieceProcessor {
const fileContent: ProjectCostSurfacesContent = {
costSurfaces: costSurfaces.map(({ id, ...costSurface }) => ({
...costSurface,
data: costSurfaceData.filter((data : CostSurfaceDataSelectResult) => data.cost_surface_id === id)
data: costSurfaceData
.filter(
(data: CostSurfaceDataSelectResult) => data.cost_surface_id === id,
)
.map(({ cost_surface_id, projects_pu_id, ...data }) => {
const puid = projectPusMap[projects_pu_id];
return { puid, ...data };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ import { ScenarioMetadataPieceImporter } from './scenario-metadata.piece-importe
import { ScenarioPlanningUnitsDataPieceImporter } from './scenario-planning-units-data.piece-importer';
import { ScenarioProtectedAreasPieceImporter } from './scenario-protected-areas.piece-importer';
import { ScenarioRunResultsPieceImporter } from './scenario-run-results.piece-importer';
import {
ProjectCostSurfacesPieceImporter
} from "@marxan-geoprocessing/import/pieces-importers/project-cost-surfaces.piece-importer";
import { ProjectCostSurfacesPieceImporter } from '@marxan-geoprocessing/import/pieces-importers/project-cost-surfaces.piece-importer';

@Module({
imports: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ import { ProjectsPuEntity } from '@marxan-jobs/planning-unit-geometry';
import { CHUNK_SIZE_FOR_BATCH_GEODB_OPERATIONS } from '@marxan-geoprocessing/utils/chunk-size-for-batch-geodb-operations';
import {
CostSurfaceData,
ProjectCostSurfacesContent
} from "@marxan/cloning/infrastructure/clone-piece-data/project-cost-surfaces";
import { CostSurfacePuDataEntity } from "@marxan/cost-surfaces";
ProjectCostSurfacesContent,
} from '@marxan/cloning/infrastructure/clone-piece-data/project-cost-surfaces';
import { CostSurfacePuDataEntity } from '@marxan/cost-surfaces';

@Injectable()
@PieceImportProvider()
export class ProjectCostSurfacesPieceImporter
implements ImportPieceProcessor {
export class ProjectCostSurfacesPieceImporter implements ImportPieceProcessor {
private readonly logger: Logger = new Logger(
ProjectCostSurfacesPieceImporter.name,
);
Expand All @@ -41,8 +40,7 @@ export class ProjectCostSurfacesPieceImporter

isSupported(piece: ClonePiece, kind: ResourceKind): boolean {
return (
piece === ClonePiece.ProjectCostSurfaces &&
kind === ResourceKind.Project
piece === ClonePiece.ProjectCostSurfaces && kind === ResourceKind.Project
);
}

Expand Down Expand Up @@ -99,22 +97,21 @@ export class ProjectCostSurfacesPieceImporter
});

const costSurfaceData = data.map((data: CostSurfaceData) => ({
...data,
cost_surface_id: costSurfaceId,
}))

...data,
cost_surface_id: costSurfaceId,
}));

const costSurfaceInsertData = costSurfaceData.map(
(data: CostSurfaceData) => ({
costSurfaceId: costSurfaceId,
cost: data.cost,
projectsPuId: projectPusMap[data.puid],

}),
);

costSurfacesDataInsertValues = costSurfacesDataInsertValues.concat(costSurfaceInsertData);

costSurfacesDataInsertValues = costSurfacesDataInsertValues.concat(
costSurfaceInsertData,
);
});

await Promise.all(
Expand Down

0 comments on commit a7730dc

Please sign in to comment.