Skip to content

Commit ca3330f

Browse files
committed
[TM-2411] Merge remote-tracking branch 'origin/staging' into epic/TM-2411-forms
# Conflicts: # apps/research-service/src/site-polygons/polygon-geometry-creation.service.ts
2 parents da563b3 + 9595b9a commit ca3330f

13 files changed

+1326
-76
lines changed

apps/research-service/src/site-polygons/dto/site-polygon.dto.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ export class SitePolygonLightDto extends HybridSupportDto {
182182
description: "Whether the site polygon is active"
183183
})
184184
isActive: boolean;
185+
186+
@ApiProperty({ nullable: true, type: Date })
187+
createdAt: Date | null;
185188
}
186189

187190
@JsonApiDto({ type: "sitePolygons" })

apps/research-service/src/site-polygons/geometry-upload.processor.ts

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ import { SitePolygonLightDto } from "./dto/site-polygon.dto";
1212
import { populateDto } from "@terramatch-microservices/common/dto/json-api-attributes";
1313
import { ValidationDto } from "../validations/dto/validation.dto";
1414
import { FeatureCollection } from "geojson";
15-
import { Feature, CreateSitePolygonRequestDto, AttributeChangesDto } from "./dto/create-site-polygon-request.dto";
15+
import { Feature, CreateSitePolygonRequestDto } from "./dto/create-site-polygon-request.dto";
1616
import { SitePolygon } from "@terramatch-microservices/database/entities";
1717
import { Op } from "sequelize";
1818
import { BadRequestException } from "@nestjs/common";
1919
import { validateSitePolygonProperties } from "./utils/site-polygon-property-validator";
20+
import { convertPropertiesToAttributeChanges } from "./utils/attribute-changes-converter";
2021
import { CriteriaId, ValidationType } from "@terramatch-microservices/database/constants";
2122

2223
export interface GeometryUploadJobData {
@@ -247,7 +248,7 @@ export class GeometryUploadProcessor extends DelayedJobWorker<GeometryUploadJobD
247248
}
248249

249250
const validatedProperties = validateSitePolygonProperties(allProperties);
250-
const attributeChanges = this.convertPropertiesToAttributeChanges(validatedProperties);
251+
const attributeChanges = convertPropertiesToAttributeChanges(validatedProperties);
251252

252253
const uploadedPolyName = attributeChanges.polyName ?? attributeChanges.poly_name;
253254
const basePolyName = basePolygon.polyName ?? null;
@@ -318,40 +319,4 @@ export class GeometryUploadProcessor extends DelayedJobWorker<GeometryUploadJobD
318319
payload: document
319320
};
320321
}
321-
322-
private convertPropertiesToAttributeChanges(properties: Partial<SitePolygon>): AttributeChangesDto {
323-
const attributeChanges: AttributeChangesDto = {};
324-
325-
if (properties.polyName != null) {
326-
attributeChanges.polyName = properties.polyName;
327-
attributeChanges.poly_name = properties.polyName;
328-
}
329-
330-
if (properties.plantStart != null) {
331-
const plantStartString =
332-
properties.plantStart instanceof Date ? properties.plantStart.toISOString() : String(properties.plantStart);
333-
attributeChanges.plantStart = plantStartString;
334-
attributeChanges.plantstart = plantStartString;
335-
}
336-
337-
if (properties.practice != null && properties.practice.length > 0) {
338-
attributeChanges.practice = properties.practice;
339-
}
340-
341-
if (properties.targetSys != null) {
342-
attributeChanges.targetSys = properties.targetSys;
343-
attributeChanges.target_sys = properties.targetSys;
344-
}
345-
346-
if (properties.distr != null && properties.distr.length > 0) {
347-
attributeChanges.distr = properties.distr;
348-
}
349-
350-
if (properties.numTrees != null) {
351-
attributeChanges.numTrees = properties.numTrees;
352-
attributeChanges.num_trees = properties.numTrees;
353-
}
354-
355-
return attributeChanges;
356-
}
357322
}

0 commit comments

Comments
 (0)