Skip to content

Commit 762047a

Browse files
authored
fix: update PolygonPartsProcessPayload to include shouldClearEntities (#85)
* fix: update PolygonPartsProcessPayload to include shouldClearEntities and adjust job processing logic * fix: correct indentation in polygonPartsManagerClient test for clarity
1 parent e7b7237 commit 762047a

5 files changed

Lines changed: 25 additions & 9 deletions

File tree

src/common/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ export type CatalogUpdateMetadata = Partial<RasterLayerMetadata>;
344344
//#endregion catalogClient
345345

346346
//#region PolygonPartsManagerClient
347-
export type PolygonPartsProcessPayload = Pick<PolygonPartsPayload, 'productId' | 'productType' | 'jobType'>;
347+
export type PolygonPartsProcessPayload = Pick<PolygonPartsPayload, 'productId' | 'productType'> & { shouldClearEntities?: boolean };
348348
//#endregion PolygonPartsManagerClient
349349

350350
//#region seedingJobCreator

src/job/models/ingestion/newJobHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ export class NewJobHandler
120120
activeSpan?.addEvent('layerNames.valid', { layerName });
121121

122122
if (!processedParts) {
123-
const { type, resourceId, productType } = job;
124-
await this.polygonPartsMangerClient.process({ jobType: type, productId: resourceId, productType });
123+
const { resourceId, productType } = job;
124+
await this.polygonPartsMangerClient.process({ productId: resourceId, productType });
125125
finalizeTaskParams = await this.markFinalizeStepAsCompleted(job.id, task.id, finalizeTaskParams, 'processedParts');
126126

127127
activeSpan?.addEvent('processPolygonParts.success', { ...finalizeTaskParams });

src/job/models/ingestion/swapJobHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ export class SwapJobHandler
117117
const { tileOutputFormat, displayPath } = job.parameters.additionalParams;
118118

119119
if (!processedParts) {
120-
const { type, resourceId, productType } = job;
120+
const { resourceId, productType } = job;
121121

122-
await this.polygonPartsMangerClient.process({ jobType: type, productId: resourceId, productType });
122+
await this.polygonPartsMangerClient.process({ shouldClearEntities: true, productId: resourceId, productType });
123123
finalizeTaskParams = await this.markFinalizeStepAsCompleted(job.id, task.id, finalizeTaskParams, 'processedParts');
124124

125125
activeSpan?.addEvent('processPolygonParts.success', { ...finalizeTaskParams });

src/job/models/ingestion/updateJobHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ export class UpdateJobHandler
106106
activeSpan?.addEvent('layerNameFormat.valid', { layerName: layerNameFormats.layerName });
107107

108108
if (!processedParts) {
109-
const { type, resourceId, productType } = job;
109+
const { resourceId, productType } = job;
110110

111-
await this.polygonPartsMangerClient.process({ jobType: type, productId: resourceId, productType });
111+
await this.polygonPartsMangerClient.process({ productId: resourceId, productType });
112112
finalizeTaskParams = await this.markFinalizeStepAsCompleted(job.id, task.id, finalizeTaskParams, 'processedParts');
113113

114114
activeSpan?.addEvent('processPolygonParts.success', { ...finalizeTaskParams });

tests/unit/httpClients/polygonPartMangerClient.spec.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,24 @@ describe('polygonPartsManagerClient', () => {
2525

2626
const baseUrl = configMock.get<string>('servicesUrl.polygonPartsManager');
2727
const payload: PolygonPartsProcessPayload = {
28-
jobType: 'Ingestion_New',
28+
productId: 'test_layer',
29+
productType: RasterProductTypes.ORTHOPHOTO,
30+
};
31+
const url = '/polygonParts/process';
32+
nock(baseUrl).put(url, payload).reply(200);
33+
34+
const action = polygonPartsManagerClient.process(payload);
35+
36+
await expect(action).resolves.toBeUndefined();
37+
expect(nock.isDone()).toBe(true);
38+
});
39+
40+
it('should process polygon parts and replacing old data successfully', async () => {
41+
polygonPartsManagerClient = new PolygonPartsMangerClient(configMock, jsLogger({ enabled: false }));
42+
43+
const baseUrl = configMock.get<string>('servicesUrl.polygonPartsManager');
44+
const payload: PolygonPartsProcessPayload = {
45+
shouldClearEntities: true,
2946
productId: 'test_layer',
3047
productType: RasterProductTypes.ORTHOPHOTO,
3148
};
@@ -43,7 +60,6 @@ describe('polygonPartsManagerClient', () => {
4360

4461
const baseUrl = configMock.get<string>('servicesUrl.polygonPartsManager');
4562
const payload: PolygonPartsProcessPayload = {
46-
jobType: 'Ingestion_New',
4763
productId: 'test_layer',
4864
productType: RasterProductTypes.ORTHOPHOTO,
4965
};

0 commit comments

Comments
 (0)