mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
add includeSpaces in the query param
This commit is contained in:
@ -100,26 +100,29 @@ export class CommunityService {
|
||||
const { baseResponseDto, paginationResponseDto } =
|
||||
await customModel.findAll(pageable);
|
||||
|
||||
const communitiesWithSpaces = await Promise.all(
|
||||
baseResponseDto.data.map(async (community: CommunityDto) => {
|
||||
const spaces = await this.spaceService.getSpacesHierarchyForCommunity(
|
||||
{
|
||||
communityUuid: community.uuid,
|
||||
projectUuid: param.projectUuid,
|
||||
},
|
||||
{
|
||||
onlyWithDevices: false,
|
||||
},
|
||||
);
|
||||
if (pageable.includeSpaces) {
|
||||
const communitiesWithSpaces = await Promise.all(
|
||||
baseResponseDto.data.map(async (community: CommunityDto) => {
|
||||
const spaces =
|
||||
await this.spaceService.getSpacesHierarchyForCommunity(
|
||||
{
|
||||
communityUuid: community.uuid,
|
||||
projectUuid: param.projectUuid,
|
||||
},
|
||||
{
|
||||
onlyWithDevices: false,
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
...community,
|
||||
spaces: spaces.data,
|
||||
};
|
||||
}),
|
||||
);
|
||||
return {
|
||||
...community,
|
||||
spaces: spaces.data,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
baseResponseDto.data = communitiesWithSpaces;
|
||||
baseResponseDto.data = communitiesWithSpaces;
|
||||
}
|
||||
|
||||
return new PageResponse<CommunityDto>(
|
||||
baseResponseDto,
|
||||
|
Reference in New Issue
Block a user