From a17b91b1f5529ec239ed43287e4b7ec4cc129c2e Mon Sep 17 00:00:00 2001 From: Abdul Rahman Reza Date: Mon, 2 Dec 2024 21:12:48 +0700 Subject: [PATCH] update function common filter --- src/controllers/user_activity.ts | 2 -- src/helpers/common.ts | 10 +--------- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/controllers/user_activity.ts b/src/controllers/user_activity.ts index 6c8495f..f0e4d11 100644 --- a/src/controllers/user_activity.ts +++ b/src/controllers/user_activity.ts @@ -78,8 +78,6 @@ export class UserActivityController { token: Joi.string().required().label('Token'), }); - - const param: PagingActivity = await schema.validateAsync(req.query); const userRepository = OrmHelper.DB.getRepository(UserActivity); diff --git a/src/helpers/common.ts b/src/helpers/common.ts index a0e3d0d..b36a8a0 100644 --- a/src/helpers/common.ts +++ b/src/helpers/common.ts @@ -192,15 +192,7 @@ export default class CommonHelper { } } - const whereAttr = whereAttrPre.join(' and ') + (whereAttrPre.length > 0 && param.additional_where != '' ? ' and ' : '') + (param.additional_where ?? ''); - - // let whereAttr = ''; - // if (whereAttrPre.length > 0) { - // whereAttr = whereAttrPre.join(' and ') + (whereAttrPre.length > 0 && param.additional_where != '' ? ' and ' : '') + (param.additional_where ?? ''); - // } else { - // whereAttr += param.additional_where; - // } - + const whereAttr = whereAttrPre.join(' and ') + (whereAttrPre.length > 0 && param.additional_where && param.additional_where != '' ? ' and ' : '') + (param.additional_where ?? ''); return { whereAttr, whereVal }; }