diff --git a/src/controllers/user/post.controller.ts b/src/controllers/user/post.controller.ts index 50c23041c..80690e0a0 100644 --- a/src/controllers/user/post.controller.ts +++ b/src/controllers/user/post.controller.ts @@ -107,7 +107,7 @@ export class UserPostController { } @intercept(PaginationInterceptor.BINDING_KEY) - @get('/user/profile//posts/{id}') + @get('/user/profile/{id}/posts') @response(200, { description: 'Array of Post model instances', content: { diff --git a/src/enums/method-type.enum.ts b/src/enums/method-type.enum.ts index ee58dc96e..d43782bec 100644 --- a/src/enums/method-type.enum.ts +++ b/src/enums/method-type.enum.ts @@ -28,5 +28,4 @@ export enum MethodType { UPDATEEXPERIENCE = 'updateExperience', UPDATEPRIMARY = 'updatePrimary', VERIFY = 'verify', - FINDBYPROFILE = 'findByProfile', } diff --git a/src/interceptors/pagination.interceptor.ts b/src/interceptors/pagination.interceptor.ts index ad016176a..7de94b9fa 100644 --- a/src/interceptors/pagination.interceptor.ts +++ b/src/interceptors/pagination.interceptor.ts @@ -97,8 +97,8 @@ export class PaginationInterceptor implements Provider { ) { const {query} = await invocationCtx.get(RestBindings.Http.REQUEST); const {pageNumber, pageLimit} = query; - const filter = await this.beforePagination(invocationCtx, query); + const filter = await this.beforePagination(invocationCtx, query); const meta = await this.initializeMeta(invocationCtx, filter, [ Number(pageNumber), Number(pageLimit), @@ -123,7 +123,7 @@ export class PaginationInterceptor implements Provider { ): Promise> { const methodName = invocationCtx.methodName as MethodType; const controllerName = invocationCtx.targetClass.name as ControllerType; - const filter = this.initializeFilter(invocationCtx, methodName); + const filter = this.initializeFilter(invocationCtx); switch (controllerName) { case ControllerType.USER: { @@ -594,16 +594,10 @@ export class PaginationInterceptor implements Provider { pageDetail: number[], ): Promise { const controllerName = invocationCtx.targetClass.name as ControllerType; - let additionalData = invocationCtx.args[0]; - if ( - controllerName === ControllerType.USERPOST && - invocationCtx.methodName === MethodType.FIND - ) - additionalData = undefined; const {count} = await this.metricService.countData( controllerName, filter, - additionalData, + invocationCtx.args[0], ); const meta = pageMetadata([...pageDetail, count]); @@ -635,17 +629,10 @@ export class PaginationInterceptor implements Provider { }; } - private initializeFilter( - invocationCtx: InvocationContext, - method: MethodType, - ): AnyObject { - let num = 0; - if (method === MethodType.FINDBYPROFILE) { - num = 1; - } + private initializeFilter(invocationCtx: InvocationContext): AnyObject { const filter = - invocationCtx.args[num] && typeof invocationCtx.args[num] === 'object' - ? invocationCtx.args[num] + invocationCtx.args[0] && typeof invocationCtx.args[0] === 'object' + ? invocationCtx.args[0] : {where: {}}; filter.where = {...filter.where}; @@ -677,7 +664,6 @@ export class PaginationInterceptor implements Provider { } if (methodName === MethodType.GETIMPORTERS) return 2; - if (methodName === MethodType.FINDBYPROFILE) return 1; return 0; } } diff --git a/src/services/metric.service.ts b/src/services/metric.service.ts index f45ae77f9..7c199657b 100644 --- a/src/services/metric.service.ts +++ b/src/services/metric.service.ts @@ -348,13 +348,6 @@ export class MetricService { case ControllerType.EXPERIENCEPOST: case ControllerType.USERPOST: - if (additionalData) { - const newWhere = { - createdBy: additionalData, - banned: false, - }; - return this.postRepository.count(newWhere); - } case ControllerType.POST: return this.postRepository.count(where); diff --git a/src/services/post.service.ts b/src/services/post.service.ts index f11c65253..7e45917f4 100644 --- a/src/services/post.service.ts +++ b/src/services/post.service.ts @@ -265,8 +265,8 @@ export class PostService { id: string, filter?: Filter, ): Promise { - const where = filter?.where ?? {createdBy: id}; return this.postRepository.find({ + ...filter, where: { createdBy: id, },