From 63f1f7a7c05c5e2720a3ab8a973dd9516c7603dc Mon Sep 17 00:00:00 2001 From: hannathkadher Date: Sun, 9 Mar 2025 14:03:59 +0400 Subject: [PATCH] fixed get spaces --- .../space-model-product-allocation.service.ts | 13 ------------- src/space/services/space.service.ts | 3 ++- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/space-model/services/space-model-product-allocation.service.ts b/src/space-model/services/space-model-product-allocation.service.ts index d895500..d57a6af 100644 --- a/src/space-model/services/space-model-product-allocation.service.ts +++ b/src/space-model/services/space-model-product-allocation.service.ts @@ -14,7 +14,6 @@ import { ModifyAction } from '@app/common/constants/modify-action.enum'; import { NewTagEntity } from '@app/common/modules/tag'; import { ProductEntity } from '@app/common/modules/product/entities'; import { SpaceRepository } from '@app/common/modules/space'; -import { SpaceProductAllocationService } from 'src/space/services/space-product-allocation.service'; import { SpaceEntity } from '@app/common/modules/space/entities/space.entity'; @Injectable() @@ -23,7 +22,6 @@ export class SpaceModelProductAllocationService { private readonly tagService: NewTagService, private readonly spaceModelProductAllocationRepository: SpaceModelProductAllocationRepoitory, private readonly spaceRepository: SpaceRepository, - private readonly spaceProductAllocationService: SpaceProductAllocationService, ) {} async createProductAllocations( @@ -114,23 +112,12 @@ export class SpaceModelProductAllocationService { } else if (!allocation.tags.some((t) => t.uuid === tag.uuid)) { allocation.tags.push(tag); await this.saveAllocation(allocation, queryRunner); - await this.spaceProductAllocationService.addTagToAllocationFromModel( - allocation, - queryRunner, - tag, - spaces, - ); } } } if (productAllocations.length > 0) { await this.saveAllocations(productAllocations, queryRunner); - await this.spaceProductAllocationService.createAllocationFromModel( - productAllocations, - queryRunner, - spaces, - ); } return productAllocations; diff --git a/src/space/services/space.service.ts b/src/space/services/space.service.ts index 844c42f..46e584b 100644 --- a/src/space/services/space.service.ts +++ b/src/space/services/space.service.ts @@ -276,10 +276,11 @@ export class SpaceService { const spaces = await queryBuilder.getMany(); const transformedSpaces = spaces.map(this.transformSpace); + const spaceHierarchy = this.buildSpaceHierarchy(transformedSpaces); return new SuccessResponseDto({ message: `Spaces in community ${communityUuid} successfully fetched in hierarchy`, - data: onlyWithDevices ? spaces : transformedSpaces, + data: onlyWithDevices ? spaces : spaceHierarchy, statusCode: HttpStatus.OK, }); } catch (error) {