This commit is contained in:
hannathkadher
2025-02-17 22:19:52 +04:00
parent 565b0f72b7
commit 61a85789d1
3 changed files with 4 additions and 25 deletions

15
package-lock.json generated
View File

@ -6896,21 +6896,6 @@
"dev": true,
"license": "ISC"
},
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",

View File

@ -5,11 +5,7 @@ import {
SpaceModelRepository,
} from '@app/common/modules/space-model';
import { HttpException, HttpStatus, Injectable } from '@nestjs/common';
import {
CreateSpaceModelDto,
CreateSubspaceModelDto,
UpdateSpaceModelDto,
} from '../dtos';
import { CreateSpaceModelDto, UpdateSpaceModelDto } from '../dtos';
import { ProjectParam } from 'src/community/dtos';
import { SuccessResponseDto } from '@app/common/dto/success.response.dto';
import { SubSpaceModelService } from './subspace/subspace-model.service';
@ -58,7 +54,7 @@ export class SpaceModelService {
const queryRunner = this.dataSource.createQueryRunner();
await queryRunner.connect();
await queryRunner.startTransaction();
console.log("c");
try {
const project = await this.validateProject(params.projectUuid);
@ -106,12 +102,13 @@ export class SpaceModelService {
statusCode: HttpStatus.CREATED,
});
} catch (error) {
console.log("jj");
await queryRunner.rollbackTransaction();
const errorMessage =
error instanceof HttpException
? error.message
: 'An unexpected error occurred';
: `An unexpected error occurred ${error.message}`;
const statusCode =
error instanceof HttpException
? error.getStatus()

View File

@ -53,19 +53,16 @@ export class SubSpaceModelService {
subspaceEntities.push(subspaceModel);
}
// Save all subspaces in bulk
const savedSubspaces = await queryRunner.manager.save(subspaceEntities);
for (const [index, dto] of dtos.entries()) {
const subspaceModel = savedSubspaces[index];
// Process tags for this subspace
const processedTags = await this.tagService.processTags(
dto.tags,
spaceModel.project.uuid,
);
// Create Product Allocations for Subspace Model
await this.createSubspaceProductAllocations(subspaceModel, processedTags);
}
return savedSubspaces;