From 14828f9d1fa43c683d6434dc3b2aea9000ebff1c Mon Sep 17 00:00:00 2001 From: Priyanka Pradeep Date: Mon, 4 Apr 2022 10:45:39 +0530 Subject: [PATCH] 4.8 optimization from loadtest branch --- models/project-template-tasks.js | 3 ++- models/project-templates.js | 3 ++- models/projects.js | 13 ++++++++--- module/userProjects/helper.js | 39 ++++++++++++++++---------------- 4 files changed, 34 insertions(+), 24 deletions(-) diff --git a/models/project-template-tasks.js b/models/project-template-tasks.js index d2d14db6..bdfb20bd 100644 --- a/models/project-template-tasks.js +++ b/models/project-template-tasks.js @@ -25,7 +25,8 @@ module.exports = { }, isDeleted : { type : Boolean, - default : false + default : false, + index: true }, externalId : { type : String, diff --git a/models/project-templates.js b/models/project-templates.js index 45d1604e..a4620368 100644 --- a/models/project-templates.js +++ b/models/project-templates.js @@ -45,7 +45,8 @@ module.exports = { }, isDeleted : { type : Boolean, - default : false + default : false, + index: true }, recommendedFor : { type : Array, diff --git a/models/projects.js b/models/projects.js index 597b8d2d..d67879cb 100644 --- a/models/projects.js +++ b/models/projects.js @@ -8,8 +8,14 @@ module.exports = { name: "projects", schema: { - title : String, - description : String, + title : { + type : String, + index: true + }, + description : { + type : String, + index: true + }, taskReport : { type : Object, default : {} @@ -46,7 +52,8 @@ module.exports = { }, createdBy : { type : String, - default : "SYSTEM" + default : "SYSTEM", + index: true }, tasks : { type : Array, diff --git a/module/userProjects/helper.js b/module/userProjects/helper.js index d06fab0f..1bb4d063 100644 --- a/module/userProjects/helper.js +++ b/module/userProjects/helper.js @@ -1690,12 +1690,14 @@ module.exports = class UserProjectsHelper { if ( filter && filter !== "" ) { if( filter === CONSTANTS.common.CREATED_BY_ME ) { - query["isAPrivateProgram"] = { - $ne : false - }; query["referenceFrom"] = { $ne : CONSTANTS.common.LINK }; + + query["isAPrivateProgram"] = { + $ne : false + }; + } else if( filter == CONSTANTS.common.ASSIGN_TO_ME ) { query["isAPrivateProgram"] = false; } else{ @@ -1725,30 +1727,29 @@ module.exports = class UserProjectsHelper { let totalCount = 0; let data = []; - if( projects.success && projects.data ) { + if( projects.success && projects.data && projects.data.data && Object.keys(projects.data.data).length > 0 ) { totalCount = projects.data.count; data = projects.data.data; - if( data.length > 0 ) { - data.forEach( projectData => { - projectData.name = projectData.title; + data.forEach( projectData => { + projectData.name = projectData.title; - if (projectData.programInformation) { - projectData.programName = projectData.programInformation.name; - delete projectData.programInformation; - } + if (projectData.programInformation) { + projectData.programName = projectData.programInformation.name; + delete projectData.programInformation; + } - if (projectData.solutionExternalId) { - projectData.externalId = projectData.solutionExternalId; - delete projectData.solutionExternalId; - } + if (projectData.solutionExternalId) { + projectData.externalId = projectData.solutionExternalId; + delete projectData.solutionExternalId; + } - projectData.type = CONSTANTS.common.IMPROVEMENT_PROJECT; + projectData.type = CONSTANTS.common.IMPROVEMENT_PROJECT; - delete projectData.title; - }); - } + delete projectData.title; + }); + } return resolve({