Skip to content

Commit

Permalink
Merge pull request #26 from fga-eps-mds/hotfix/fix-addToCommunity-end…
Browse files Browse the repository at this point in the history
…point

hotfix - Fix addToCommunity and getcommunityData endpoint
  • Loading branch information
arthurarp committed Nov 4, 2021
2 parents 986a250 + 46f053c commit 4fb489f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/mapas/mapas.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
9 changes: 2 additions & 7 deletions src/mapas/mapas.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -176,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);

Expand Down Expand Up @@ -204,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(
Expand Down Expand Up @@ -272,7 +270,6 @@ export class MapasService {
found = null;
}
}

return found;
}

Expand Down Expand Up @@ -323,12 +320,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);
}
Expand Down

0 comments on commit 4fb489f

Please sign in to comment.