Skip to content

Commit

Permalink
fix: new script to add san jose map layers
Browse files Browse the repository at this point in the history
  • Loading branch information
ludtkemorgan committed Oct 16, 2024
1 parent 09f5807 commit c563ddb
Show file tree
Hide file tree
Showing 18 changed files with 66,870 additions and 38,890 deletions.
200 changes: 0 additions & 200 deletions api/prisma/migrations/06_add_geolayers_districts/migration.sql

This file was deleted.

38,683 changes: 0 additions & 38,683 deletions api/prisma/migrations/06_add_geolayers_redline/migration.sql

This file was deleted.

8 changes: 6 additions & 2 deletions api/prisma/seed-staging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ export const stagingSeed = async (
roles: { isAdmin: true },
email: '[email protected]',
confirmedAt: new Date(),
jurisdictionIds: [jurisdiction.id, sanMateoJurisdiction.id, sanJoseJurisdiction.id],
jurisdictionIds: [
jurisdiction.id,
sanMateoJurisdiction.id,
sanJoseJurisdiction.id,
],
acceptedTerms: true,
password: 'abcdef',
}),
Expand Down Expand Up @@ -128,7 +132,7 @@ export const stagingSeed = async (
data: amiChartFactory(10, jurisdiction.id),
});
await prismaClient.amiChart.create({
data: amiChartFactory(8, additionalJurisdiction.id),
data: amiChartFactory(8, sanJoseJurisdiction.id),
});
// Create map layers
await prismaClient.mapLayers.create({
Expand Down
12 changes: 12 additions & 0 deletions api/src/controllers/script-runner.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,16 @@ export class ScirptRunnerController {
): Promise<SuccessDTO> {
return await this.scriptRunnerService.optOutExistingLotteries(req);
}

@Put('insertSanJoseMapLayers')
@ApiOperation({
summary: 'A script that adds map layers for San Jose',
operationId: 'insertSanJoseMapLayers',
})
@ApiOkResponse({ type: SuccessDTO })
async insertSanJoseMapLayers(
@Request() req: ExpressRequest,
): Promise<SuccessDTO> {
return await this.scriptRunnerService.insertSanJoseMapLayers(req);
}
}
5,925 changes: 5,925 additions & 0 deletions api/src/data/SanJoseDistrict1.json

Large diffs are not rendered by default.

4,617 changes: 4,617 additions & 0 deletions api/src/data/SanJoseDistrict10.json

Large diffs are not rendered by default.

7,730 changes: 7,730 additions & 0 deletions api/src/data/SanJoseDistrict2.json

Large diffs are not rendered by default.

2,138 changes: 2,138 additions & 0 deletions api/src/data/SanJoseDistrict3.json

Large diffs are not rendered by default.

10,124 changes: 10,124 additions & 0 deletions api/src/data/SanJoseDistrict4.json

Large diffs are not rendered by default.

7,681 changes: 7,681 additions & 0 deletions api/src/data/SanJoseDistrict5.json

Large diffs are not rendered by default.

6,445 changes: 6,445 additions & 0 deletions api/src/data/SanJoseDistrict6.json

Large diffs are not rendered by default.

2,267 changes: 2,267 additions & 0 deletions api/src/data/SanJoseDistrict7.json

Large diffs are not rendered by default.

2,878 changes: 2,878 additions & 0 deletions api/src/data/SanJoseDistrict8.json

Large diffs are not rendered by default.

5,626 changes: 5,626 additions & 0 deletions api/src/data/SanJoseDistrict9.json

Large diffs are not rendered by default.

11,351 changes: 11,351 additions & 0 deletions api/src/data/SanJoseRedlined.json

Large diffs are not rendered by default.

62 changes: 62 additions & 0 deletions api/src/services/script-runner.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ import { IdDTO } from '../dtos/shared/id.dto';
import { AmiChartImportDTO } from '../dtos/script-runner/ami-chart-import.dto';
import { AmiChartCreate } from '../dtos/ami-charts/ami-chart-create.dto';
import { AmiChartService } from './ami-chart.service';
import sanJoseRedlined from '../data/SanJoseRedlined.json';
import district1 from '../data/SanJoseDistrict1.json';
import district2 from '../data/SanJoseDistrict2.json';
import district3 from '../data/SanJoseDistrict3.json';
import district4 from '../data/SanJoseDistrict4.json';
import district5 from '../data/SanJoseDistrict5.json';
import district6 from '../data/SanJoseDistrict6.json';
import district7 from '../data/SanJoseDistrict7.json';
import district8 from '../data/SanJoseDistrict8.json';
import district9 from '../data/SanJoseDistrict9.json';
import district10 from '../data/SanJoseDistrict10.json';

/**
this is the service for running scripts
Expand Down Expand Up @@ -455,6 +466,57 @@ export class ScriptRunnerService {
return { success: true };
}

/**
*
* @param req incoming request object
* @returns successDTO
* @description Adds 11 new map layers for San Jose
*/
async insertSanJoseMapLayers(req: ExpressRequest): Promise<SuccessDTO> {
const requestingUser = mapTo(User, req['user']);
await this.markScriptAsRunStart('san jose map layers', requestingUser);

const sjId = await this.prisma.jurisdictions.findFirst({
select: {
id: true,
},
where: { name: 'San Jose' },
});

await this.prisma.mapLayers.create({
data: {
name: 'San Jose Redlined',
jurisdictionId: sjId.id,
featureCollection: sanJoseRedlined,
},
});

const councilDistrictMaps = [
district1,
district2,
district3,
district4,
district5,
district6,
district7,
district8,
district9,
district10,
];
councilDistrictMaps.forEach(async (disctict, index) => {
await this.prisma.mapLayers.create({
data: {
name: `San Jose District ${index + 1}`,
jurisdictionId: sjId.id,
featureCollection: disctict,
},
});
});

await this.markScriptAsComplete('san jose map layers', requestingUser);
return { success: true };
}

/**
this is simply an example
*/
Expand Down
3 changes: 2 additions & 1 deletion api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"esModuleInterop": true
"esModuleInterop": true,
"resolveJsonModule": true,
},
"exclude": ["node_modules", "dist"]
}
10 changes: 6 additions & 4 deletions sites/partners/src/components/settings/PreferenceDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -731,10 +731,12 @@ const PreferenceDrawer = ({
mapLayers
? [
{ label: "", value: "" },
...mapLayers.map((layer) => ({
label: layer.name,
value: layer.id,
})),
...mapLayers
.sort((a, b) => a.name.localeCompare(b.name))
.map((layer) => ({
label: layer.name,
value: layer.id,
})),
]
: [{ label: "", value: "" }]
}
Expand Down

0 comments on commit c563ddb

Please sign in to comment.