propagate subspace allocations

This commit is contained in:
hannathkadher
2025-03-12 21:57:08 +04:00
parent 8456eea5dc
commit 537f20f8de
6 changed files with 314 additions and 315 deletions
@@ -47,7 +47,7 @@ import { SpaceProductAllocationEntity } from '@app/common/modules/space/entities
import { SubspaceEntity } from '@app/common/modules/space/entities/subspace/subspace.entity';
import { SubspaceProductAllocationEntity } from '@app/common/modules/space/entities/subspace/subspace-product-allocation.entity';
import { DeviceEntity } from '@app/common/modules/device/entities';
import { ISingleSubspaceModel } from '../interfaces';
import { ISingleSubspaceModel, ISubspaceModelUpdates } from '../interfaces';
@Injectable()
export class SpaceModelService {
@@ -199,7 +199,7 @@ export class SpaceModelService {
param.projectUuid,
);
await queryRunner.connect();
let modifiedSubspaces: ISingleSubspaceModel[] = [];
let modifiedSubspaces: ISubspaceModelUpdates;
try {
await queryRunner.startTransaction();
const spaces = await this.fetchModelSpaces(spaceModel);
@@ -16,6 +16,7 @@ import { SubspaceModelProductAllocationService } from './subspace-model-product-
import {
IRelocatedAllocation,
ISingleSubspaceModel,
ISubspaceModelUpdates,
} from 'src/space-model/interfaces';
import { SpaceEntity } from '@app/common/modules/space/entities/space.entity';
import { SubSpaceService } from 'src/space/services/subspace';
@@ -118,7 +119,7 @@ export class SubSpaceModelService {
projectUuid: string,
spaceTagUpdateDtos?: ModifyTagModelDto[],
spaces?: SpaceEntity[],
): Promise<ISingleSubspaceModel[]> {
): Promise<ISubspaceModelUpdates> {
try {
if (!dtos || dtos.length === 0) {
return;
@@ -160,13 +161,16 @@ export class SubSpaceModelService {
spaceModel,
spaceTagUpdateDtos,
);
return [
createdSubspaces ?? [],
updatedSubspaces ?? [],
deletedSubspaces ?? [],
]
.filter((arr) => arr.length > 0)
.flat();
return {
subspaceModels: [
createdSubspaces ?? [],
updatedSubspaces ?? [],
deletedSubspaces ?? [],
]
.filter((arr) => arr.length > 0)
.flat(),
updatedAllocations: updatedAllocations,
};
} catch (error) {
console.error('Error in modifySubspaceModels:', error);
throw new HttpException(