From 9e5393b892ab972de263604d023c692dd26433db Mon Sep 17 00:00:00 2001 From: VISHNUDAS-tunerlabse Date: Sun, 25 Dec 2022 22:31:45 +0530 Subject: [PATCH] certificates API params added --- controllers/v1/userProjects.js | 5 ++++- module/userProjects/helper.js | 16 ++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/controllers/v1/userProjects.js b/controllers/v1/userProjects.js index 052a4f9b..06bb56a7 100644 --- a/controllers/v1/userProjects.js +++ b/controllers/v1/userProjects.js @@ -1065,7 +1065,10 @@ module.exports = class UserProjects extends Abstract { return new Promise(async (resolve, reject) => { try { // fetch projects data of user, whish has certificate on completion - let projectDetails = await userProjectsHelper.certificates( req.userDetails.userInformation.userId ); + let projectDetails = await userProjectsHelper.certificates( + req.userDetails.userInformation.userId, + req.params._id ? req.params._id : "" + ); return resolve({ message: projectDetails.message, result: projectDetails.data diff --git a/module/userProjects/helper.js b/module/userProjects/helper.js index fe55695c..d357b684 100644 --- a/module/userProjects/helper.js +++ b/module/userProjects/helper.js @@ -2687,19 +2687,27 @@ module.exports = class UserProjectsHelper { * @method * @name certificates * @param {String} userId - userId. + * @param {String} projectId - projectId. * @returns {JSON} certificate data updation details. */ - static certificates(userId) { + static certificates(userId, projectId = "") { return new Promise(async (resolve, reject) => { try { - // get project details of user which have certificate. - const userProject = await projectQueries.projectDocument({ + let findQuery = { userId: userId, status: CONSTANTS.common.SUBMITTED_STATUS, certificate: {$exists:true} - }, [ + } + // if projectId is passed update query + if ( projectId != "" ) { + findQuery._id = projectId + } + // get project details of user which have certificate. + const userProject = await projectQueries.projectDocument( + findQuery, + [ "_id", "title", "status",