diff --git a/api/src/openapi/schemas/survey.ts b/api/src/openapi/schemas/survey.ts index 51b61d27f2..035cb5212c 100644 --- a/api/src/openapi/schemas/survey.ts +++ b/api/src/openapi/schemas/survey.ts @@ -1,4 +1,5 @@ import { OpenAPIV3 } from 'openapi-types'; +import { GeoJSONFeature } from './geoJson'; import { updateCreateUserPropertiesSchema } from './user'; export const surveyDetailsSchema: OpenAPIV3.SchemaObject = { @@ -506,8 +507,7 @@ export const surveyBlockSchema: OpenAPIV3.SchemaObject = { nullable: true }, geojson: { - description: 'Geojson', - type: 'object', + ...(GeoJSONFeature as object), nullable: true }, sample_block_count: { diff --git a/api/src/paths/project/{projectId}/survey/{surveyId}/view.ts b/api/src/paths/project/{projectId}/survey/{surveyId}/view.ts index ae16257db4..07efd3e67c 100644 --- a/api/src/paths/project/{projectId}/survey/{surveyId}/view.ts +++ b/api/src/paths/project/{projectId}/survey/{surveyId}/view.ts @@ -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(); diff --git a/database/src/seeds/03_basic_project_survey_setup.ts b/database/src/seeds/03_basic_project_survey_setup.ts index efcf50b1bd..29af40b074 100644 --- a/database/src/seeds/03_basic_project_survey_setup.ts +++ b/database/src/seeds/03_basic_project_survey_setup.ts @@ -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": {} + }' ) ; `;