From 9b63b4c2c37f05c95c84aaad55ca24acce7a229e Mon Sep 17 00:00:00 2001 From: RXRD Date: Wed, 15 Nov 2023 12:44:34 +0700 Subject: [PATCH] format fix --- src/controllers/user/experience.controller.ts | 2 +- src/services/post.service.ts | 26 +++++----- src/services/user-experience.service.ts | 51 ++++++++++--------- src/services/user.service.ts | 2 +- 4 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/controllers/user/experience.controller.ts b/src/controllers/user/experience.controller.ts index 9a8d1520d..4b69c925d 100644 --- a/src/controllers/user/experience.controller.ts +++ b/src/controllers/user/experience.controller.ts @@ -132,6 +132,6 @@ export class UserExperienceController { experience: Partial, @param.array('editors', 'query', {type: 'string'}) editors?: string[], ): Promise { - return this.userService.updateExperience(id, experience,editors); + return this.userService.updateExperience(id, experience, editors); } } diff --git a/src/services/post.service.ts b/src/services/post.service.ts index 802611046..0415f3ad8 100644 --- a/src/services/post.service.ts +++ b/src/services/post.service.ts @@ -753,22 +753,24 @@ export class PostService { createdBy: userId, }, }); - const editable = this.experienceEditorRepository.find({ - where: { - experienceId: {inq: timelineIds}, - userId, - }, - }).then(res => { - const query = res.map(res => res.userId) - return this.experienceRepository.find({ + const editable = this.experienceEditorRepository + .find({ where: { - id: {inq: query}, + experienceId: {inq: timelineIds}, + userId, }, + }) + .then(res => { + const query = res.map(res => res.userId); + return this.experienceRepository.find({ + where: { + id: {inq: query}, + }, + }); }); + const timelines = await Promise.all([timeline, editable]).then(res => { + return [...res[0], ...res[1]]; }); - const timelines = await Promise.all([timeline,editable]).then(res => { - return [...res[0],...res[1]] - }) if (timelines.length <= 0) { throw new HttpErrors.UnprocessableEntity('TimelineNotFound'); diff --git a/src/services/user-experience.service.ts b/src/services/user-experience.service.ts index 60e71ca50..51d0b1eca 100644 --- a/src/services/user-experience.service.ts +++ b/src/services/user-experience.service.ts @@ -257,23 +257,20 @@ export class UserExperienceService { if (editors) { if (editors.includes(userId)) { - jobs.push(this.experienceRepository.editors(id).unlinkAll()) - } - else { - await this.experienceRepository.editors(id).unlinkAll(); - editors.map(editor => { - const link = this.experienceRepository - .editors(id) - .link(editor); - const creation = this.userExperienceRepository.create({ - userId: editor, - experienceId: id, + jobs.push(this.experienceRepository.editors(id).unlinkAll()); + } else { + await this.experienceRepository.editors(id).unlinkAll(); + editors.map(editor => { + const link = this.experienceRepository.editors(id).link(editor); + const creation = this.userExperienceRepository.create({ + userId: editor, + experienceId: id, + }); + jobs.push(link); + jobs.push(creation); + return editor; }); - jobs.push(link); - jobs.push(creation); - return editor; - }); -} + } } Promise.all(jobs) as Promise; @@ -332,16 +329,22 @@ export class UserExperienceService { const promises: Promise[] = []; if (experience) { - const editors = await this.experienceRepository.editors(experience.id).find({ - where: { - id: userId - } - }) + const editors = await this.experienceRepository + .editors(experience.id) + .find({ + where: { + id: userId, + }, + }); if (editors) { editors.map(editor => { - promises.push(this.experienceRepository.editors(experience.id).unlink(editor.id)); - return editor - }) + promises.push( + this.experienceRepository + .editors(experience.id) + .unlink(editor.id), + ); + return editor; + }); } } diff --git a/src/services/user.service.ts b/src/services/user.service.ts index d4cd90d84..0ecd3b5a0 100644 --- a/src/services/user.service.ts +++ b/src/services/user.service.ts @@ -806,7 +806,7 @@ export class UserService { ): Promise { experience.createdBy = this.currentUser[securityId]; - return this.userExperienceService.update(id, experience,editors); + return this.userExperienceService.update(id, experience, editors); } public async unsubscribeExperience(id: string): Promise {