mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 08:34:55 +00:00
removed logs
This commit is contained in:
@ -211,7 +211,6 @@ export class SpaceModelService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (dto.subspaceModels) {
|
if (dto.subspaceModels) {
|
||||||
console.log(JSON.stringify(modifiedSubspaces));
|
|
||||||
modifiedSubspaceModels =
|
modifiedSubspaceModels =
|
||||||
await this.subSpaceModelService.modifySubSpaceModels(
|
await this.subSpaceModelService.modifySubSpaceModels(
|
||||||
modifiedSubspaces,
|
modifiedSubspaces,
|
||||||
|
|||||||
@ -146,7 +146,7 @@ export class TagModelService {
|
|||||||
tag.subspaceModel = subspaceModel;
|
tag.subspaceModel = subspaceModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subspaceModel === null && spaceModel) {
|
if (!subspaceModel && spaceModel) {
|
||||||
await queryRunner.manager.update(
|
await queryRunner.manager.update(
|
||||||
this.tagModelRepository.target,
|
this.tagModelRepository.target,
|
||||||
{ uuid: tag.uuid },
|
{ uuid: tag.uuid },
|
||||||
|
|||||||
@ -172,8 +172,6 @@ export class SpaceService {
|
|||||||
): Promise<BaseResponseDto> {
|
): Promise<BaseResponseDto> {
|
||||||
const { communityUuid, projectUuid } = params;
|
const { communityUuid, projectUuid } = params;
|
||||||
const { onlyWithDevices } = getSpaceDto;
|
const { onlyWithDevices } = getSpaceDto;
|
||||||
console.log('onlyWithDevices', onlyWithDevices);
|
|
||||||
|
|
||||||
await this.validationService.validateCommunityAndProject(
|
await this.validationService.validateCommunityAndProject(
|
||||||
communityUuid,
|
communityUuid,
|
||||||
projectUuid,
|
projectUuid,
|
||||||
@ -244,12 +242,53 @@ export class SpaceService {
|
|||||||
async findOne(params: GetSpaceParam): Promise<BaseResponseDto> {
|
async findOne(params: GetSpaceParam): Promise<BaseResponseDto> {
|
||||||
const { communityUuid, spaceUuid, projectUuid } = params;
|
const { communityUuid, spaceUuid, projectUuid } = params;
|
||||||
try {
|
try {
|
||||||
const space =
|
await this.validationService.validateCommunityAndProject(
|
||||||
await this.validationService.validateSpaceWithinCommunityAndProject(
|
communityUuid,
|
||||||
communityUuid,
|
projectUuid,
|
||||||
projectUuid,
|
);
|
||||||
spaceUuid,
|
|
||||||
);
|
const queryBuilder = this.spaceRepository
|
||||||
|
.createQueryBuilder('space')
|
||||||
|
.leftJoinAndSelect('space.parent', 'parent')
|
||||||
|
.leftJoinAndSelect(
|
||||||
|
'space.children',
|
||||||
|
'children',
|
||||||
|
'children.disabled = :disabled',
|
||||||
|
{ disabled: false },
|
||||||
|
)
|
||||||
|
.leftJoinAndSelect(
|
||||||
|
'space.incomingConnections',
|
||||||
|
'incomingConnections',
|
||||||
|
'incomingConnections.disabled = :incomingConnectionDisabled',
|
||||||
|
{ incomingConnectionDisabled: false },
|
||||||
|
)
|
||||||
|
.leftJoinAndSelect(
|
||||||
|
'space.tags',
|
||||||
|
'tags',
|
||||||
|
'tags.disabled = :tagDisabled',
|
||||||
|
{ tagDisabled: false },
|
||||||
|
)
|
||||||
|
.leftJoinAndSelect('tags.product', 'tagProduct')
|
||||||
|
.leftJoinAndSelect(
|
||||||
|
'space.subspaces',
|
||||||
|
'subspaces',
|
||||||
|
'subspaces.disabled = :subspaceDisabled',
|
||||||
|
{ subspaceDisabled: false },
|
||||||
|
)
|
||||||
|
.leftJoinAndSelect(
|
||||||
|
'subspaces.tags',
|
||||||
|
'subspaceTags',
|
||||||
|
'subspaceTags.disabled = :subspaceTagsDisabled',
|
||||||
|
{ subspaceTagsDisabled: false },
|
||||||
|
)
|
||||||
|
.leftJoinAndSelect('subspaceTags.product', 'subspaceTagProduct')
|
||||||
|
.where('space.community_id = :communityUuid', { communityUuid })
|
||||||
|
.andWhere('space.spaceName != :orphanSpaceName', {
|
||||||
|
orphanSpaceName: ORPHAN_SPACE_NAME,
|
||||||
|
})
|
||||||
|
.andWhere('space.disabled = :disabled', { disabled: false });
|
||||||
|
|
||||||
|
const space = await queryBuilder.getOne();
|
||||||
|
|
||||||
return new SuccessResponseDto({
|
return new SuccessResponseDto({
|
||||||
message: `Space with ID ${spaceUuid} successfully fetched`,
|
message: `Space with ID ${spaceUuid} successfully fetched`,
|
||||||
@ -323,8 +362,7 @@ export class SpaceService {
|
|||||||
updateSpaceDto: UpdateSpaceDto,
|
updateSpaceDto: UpdateSpaceDto,
|
||||||
): Promise<BaseResponseDto> {
|
): Promise<BaseResponseDto> {
|
||||||
const { communityUuid, spaceUuid, projectUuid } = params;
|
const { communityUuid, spaceUuid, projectUuid } = params;
|
||||||
console.log(communityUuid, spaceUuid, projectUuid);
|
|
||||||
console.log(updateSpaceDto);
|
|
||||||
const queryRunner = this.dataSource.createQueryRunner();
|
const queryRunner = this.dataSource.createQueryRunner();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -82,34 +82,12 @@ export class SubspaceDeviceService {
|
|||||||
|
|
||||||
const subspace = await this.findSubspace(subSpaceUuid);
|
const subspace = await this.findSubspace(subSpaceUuid);
|
||||||
const device = await this.findDevice(deviceUuid);
|
const device = await this.findDevice(deviceUuid);
|
||||||
console.log(device);
|
|
||||||
|
|
||||||
if (device.tag) {
|
if (device.tag?.subspace?.uuid !== subspace.uuid) {
|
||||||
console.log(device.tag);
|
await this.tagRepository.update(
|
||||||
const tag = device.tag;
|
{ uuid: device.tag.uuid },
|
||||||
if (tag.subspace !== null && tag.subspace.uuid === subspace.uuid) {
|
{ subspace },
|
||||||
//do nothing
|
);
|
||||||
}
|
|
||||||
if (tag.subspace !== null && tag.subspace.uuid !== subspace.uuid) {
|
|
||||||
await this.tagRepository.update(
|
|
||||||
{
|
|
||||||
uuid: tag.uuid,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
subspace: subspace,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (tag.subspace === null) {
|
|
||||||
await this.tagRepository.update(
|
|
||||||
{
|
|
||||||
uuid: tag.uuid,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
subspace: subspace,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
device.subspace = subspace;
|
device.subspace = subspace;
|
||||||
@ -154,24 +132,13 @@ export class SubspaceDeviceService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device.tag) {
|
if (device.tag?.subspace !== null) {
|
||||||
console.log(device.tag);
|
await this.tagRepository.update(
|
||||||
const tag = device.tag;
|
{ uuid: device.tag.uuid },
|
||||||
if (tag.subspace === null) {
|
{ subspace: null, space: device.subspace },
|
||||||
//do nothing
|
);
|
||||||
}
|
|
||||||
if (tag.subspace !== null) {
|
|
||||||
await this.tagRepository.update(
|
|
||||||
{
|
|
||||||
uuid: tag.uuid,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
subspace: null,
|
|
||||||
space: device.subspace,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
device.subspace = null;
|
device.subspace = null;
|
||||||
const updatedDevice = await this.deviceRepository.save(device);
|
const updatedDevice = await this.deviceRepository.save(device);
|
||||||
|
|
||||||
|
|||||||
@ -31,13 +31,10 @@ export class TagService {
|
|||||||
|
|
||||||
const combinedTags = this.combineTags(tags, additionalTags);
|
const combinedTags = this.combineTags(tags, additionalTags);
|
||||||
this.ensureNoDuplicateTags(combinedTags);
|
this.ensureNoDuplicateTags(combinedTags);
|
||||||
console.log(tags);
|
|
||||||
|
|
||||||
const tagEntitiesToCreate = tags.filter((tagDto) => !tagDto.uuid);
|
const tagEntitiesToCreate = tags.filter((tagDto) => !tagDto.uuid);
|
||||||
const tagEntitiesToUpdate = tags.filter((tagDto) => tagDto.uuid !== null);
|
const tagEntitiesToUpdate = tags.filter((tagDto) => tagDto.uuid !== null);
|
||||||
|
|
||||||
console.log(tagEntitiesToCreate);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const createdTags = await this.bulkSaveTags(
|
const createdTags = await this.bulkSaveTags(
|
||||||
tagEntitiesToCreate,
|
tagEntitiesToCreate,
|
||||||
@ -81,8 +78,7 @@ export class TagService {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
console.log('here');
|
|
||||||
console.log(JSON.stringify(tags));
|
|
||||||
try {
|
try {
|
||||||
return await queryRunner.manager.save(tagEntities);
|
return await queryRunner.manager.save(tagEntities);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -128,7 +124,7 @@ export class TagService {
|
|||||||
tag.subspace = subspace;
|
tag.subspace = subspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subspace === null && space) {
|
if (!subspace && space) {
|
||||||
await queryRunner.manager.update(
|
await queryRunner.manager.update(
|
||||||
this.tagRepository.target,
|
this.tagRepository.target,
|
||||||
{ uuid: tag.uuid },
|
{ uuid: tag.uuid },
|
||||||
@ -187,7 +183,7 @@ export class TagService {
|
|||||||
|
|
||||||
const contextSpace = space ?? subspace?.space;
|
const contextSpace = space ?? subspace?.space;
|
||||||
|
|
||||||
if (contextSpace) {
|
if (contextSpace && tag.tag !== existingTag.tag) {
|
||||||
await this.checkTagReuse(
|
await this.checkTagReuse(
|
||||||
tag.tag,
|
tag.tag,
|
||||||
existingTag.product.uuid,
|
existingTag.product.uuid,
|
||||||
|
|||||||
Reference in New Issue
Block a user