Skip to content

Commit

Permalink
Bugfix: Survey block Openapi schema (#1443)
Browse files Browse the repository at this point in the history
- Get survey optimization
- Update survey block seed data (geojson)
  • Loading branch information
MacQSL authored Dec 4, 2024
1 parent bd62fe6 commit a7bcd49
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
4 changes: 2 additions & 2 deletions api/src/openapi/schemas/survey.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { OpenAPIV3 } from 'openapi-types';
import { GeoJSONFeature } from './geoJson';
import { updateCreateUserPropertiesSchema } from './user';

export const surveyDetailsSchema: OpenAPIV3.SchemaObject = {
Expand Down Expand Up @@ -506,8 +507,7 @@ export const surveyBlockSchema: OpenAPIV3.SchemaObject = {
nullable: true
},
geojson: {
description: 'Geojson',
type: 'object',
...(GeoJSONFeature as object),
nullable: true
},
sample_block_count: {
Expand Down
7 changes: 4 additions & 3 deletions api/src/paths/project/{projectId}/survey/{surveyId}/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,11 @@ export function getSurvey(): RequestHandler {

const surveyService = new SurveyService(connection);

const surveyData = await surveyService.getSurveyById(surveyId);

// @TODO safe to delete survey supplementary data code?
const surveySupplementaryData = await surveyService.getSurveySupplementaryDataById(Number(req.params.surveyId));
const [surveyData, surveySupplementaryData] = await Promise.all([
surveyService.getSurveyById(surveyId),
surveyService.getSurveySupplementaryDataById(surveyId)
]);

await connection.commit();

Expand Down
32 changes: 31 additions & 1 deletion database/src/seeds/03_basic_project_survey_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,37 @@ const insertSurveyBlockData = (surveyId: number) => `
${surveyId},
'${faker.lorem.words(2)}',
'${faker.lorem.words(10)}',
NULL
'{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-121.904297,
50.930738
],
[
-121.904297,
51.971346
],
[
-120.19043,
51.971346
],
[
-120.19043,
50.930738
],
[
-121.904297,
50.930738
]
]
]
},
"properties": {}
}'
)
;
`;
Expand Down

0 comments on commit a7bcd49

Please sign in to comment.