Skip to content

Commit

Permalink
Merge pull request #201 from borkarsaish65/bugfix/program_listing
Browse files Browse the repository at this point in the history
Bugfix/program listing
  • Loading branch information
aks30 authored Jan 20, 2025
2 parents 10206f0 + dc4a144 commit c9ecf67
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
13 changes: 10 additions & 3 deletions module/programs/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,9 @@ module.exports = class ProgramsHelper {
return new Promise( async (resolve, reject) => {

try {

let programDocument = [];

let matchQuery = { status : constants.common.ACTIVE };
let matchQuery = { status: constants.common.ACTIVE };

if( Object.keys(filter).length > 0 ) {
matchQuery = _.merge(matchQuery,filter);
Expand Down Expand Up @@ -498,6 +497,8 @@ module.exports = class ProgramsHelper {

programDocument.push({ $match : matchQuery }, sortQuery,{ $project : projection1 }, facetQuery, projection2);



let programDocuments =
await database.models.programs.aggregate(programDocument);

Expand Down Expand Up @@ -529,7 +530,7 @@ module.exports = class ProgramsHelper {
* @returns {JSON} - List of programs based on role and location.
*/

static forUserRoleAndLocation( bodyData, pageSize, pageNo,searchText = "" ) {
static forUserRoleAndLocation( bodyData, pageSize, pageNo,searchText = "",programId = "" ) {

return new Promise(async (resolve, reject) => {

Expand All @@ -542,6 +543,12 @@ module.exports = class ProgramsHelper {
if( !queryData.success ) {
return resolve(queryData);
}

if (programId !== "") {
queryData.data._id = gen.utils.convertStringToObjectId(programId);
}
queryData.data.startDate = { $lte: new Date() };
queryData.data.endDate = { $gte: new Date() };

let targetedPrograms = await this.list(
pageNo,
Expand Down
33 changes: 27 additions & 6 deletions module/solutions/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -711,10 +711,20 @@ module.exports = class SolutionsHelper {
matchQuery["$or"] = [];

targetedTypes.forEach( type => {

let singleType = {
type : type
};
let singleType = {};
if (type === constants.common.SURVEY) {
singleType = {
type: type,
};
const currentDate = new Date();
currentDate.setDate(currentDate.getDate() - 15);
singleType["endDate"] = { $gte: currentDate };
} else {
singleType = {
type: type,
};
singleType["endDate"] = { $gte: new Date() };
}

if( type === constants.common.IMPROVEMENT_PROJECT ) {
singleType["projectTemplateId"] = { $exists : true };
Expand All @@ -727,7 +737,15 @@ module.exports = class SolutionsHelper {
if( type !== "" ) {
matchQuery["type"] = type;
}


if (type === constants.common.SURVEY) {
const currentDate = new Date();
currentDate.setDate(currentDate.getDate() - 15);
matchQuery["endDate"] = { $gte: currentDate };
} else {
matchQuery["endDate"] = { $gte: new Date() };
}

if( subType !== "" ) {
matchQuery["subType"] = subType;
}
Expand All @@ -737,6 +755,8 @@ module.exports = class SolutionsHelper {
matchQuery["programId"] = ObjectId(programId);
}

matchQuery["startDate"] = { $lte: new Date() };

let targetedSolutions = await this.list(
type,
subType,
Expand Down Expand Up @@ -901,7 +921,8 @@ module.exports = class SolutionsHelper {
"language",
"creator",
"link",
"certificateTemplateId"
"certificateTemplateId",
"endDate"
]
);

Expand Down

0 comments on commit c9ecf67

Please sign in to comment.