Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

certificates API params added #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion controllers/v1/userProjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 12 additions & 4 deletions module/userProjects/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down