From ec69fd23f6fb81e8f82a3847e3b73f02c8030177 Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 4 Nov 2021 09:10:48 -0300 Subject: [PATCH 1/2] hotfix - Fix addToCommunity and getcommunityData endpoint Signed-off-by: Arthur --- src/mapas/mapas.controller.ts | 2 +- src/mapas/mapas.service.ts | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/mapas/mapas.controller.ts b/src/mapas/mapas.controller.ts index cfd954f..76ec5b2 100644 --- a/src/mapas/mapas.controller.ts +++ b/src/mapas/mapas.controller.ts @@ -90,7 +90,7 @@ export class MapasController { } @MessagePattern('getCommunityData') - async getCommunityData(@Payload('id') communityId: string) { + async getCommunityData(@Payload() communityId: string) { return this.mapasService.getCommunityData(communityId); } } diff --git a/src/mapas/mapas.service.ts b/src/mapas/mapas.service.ts index bac1ee0..46d3054 100644 --- a/src/mapas/mapas.service.ts +++ b/src/mapas/mapas.service.ts @@ -74,7 +74,6 @@ export class MapasService { private async getPoint(id: string) { const point = await this.pointModel.findById(id); - if (!point) throw new MicrosserviceException( 'Ponto não encontrada', @@ -272,7 +271,6 @@ export class MapasService { found = null; } } - return found; } @@ -323,12 +321,10 @@ export class MapasService { const relations = await this.communityRelationModel.find({ communityId: communityId, }); - for (const relation of relations) { const locationObject = await this.getPointOrAreaWithMedia( - relation.communityId, + relation.locationId, ); - if (locationObject instanceof PointDto) { communityDataDto.points.push(locationObject); } From 46f053cd90b95d14cfdf2d7270c2f8fcdd8a9e25 Mon Sep 17 00:00:00 2001 From: Arthur Date: Thu, 4 Nov 2021 09:36:35 -0300 Subject: [PATCH 2/2] hotfix - Add mediasList to point/area Signed-off-by: Arthur --- src/mapas/mapas.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mapas/mapas.service.ts b/src/mapas/mapas.service.ts index 46d3054..ba4352b 100644 --- a/src/mapas/mapas.service.ts +++ b/src/mapas/mapas.service.ts @@ -175,7 +175,6 @@ export class MapasService { async getAreaWithMidia(id: string) { const area = await this.getArea(id); - const areaDto = AreaDto.convertFromAreaDocument(area); areaDto.medias = await this.getMediaList(area); @@ -203,7 +202,7 @@ export class MapasService { } private async getMediaList(object: PointDocument | AreaDocument) { - return this.mediaRelationModel.find({ id: object.id }); + return await this.mediaRelationModel.find({ locationId: object.id }); } private async addMediaRelation(