diff --git a/generics/constants/common.js b/generics/constants/common.js index d8440a78..5656da9d 100644 --- a/generics/constants/common.js +++ b/generics/constants/common.js @@ -48,5 +48,6 @@ module.exports = { "DEFAULT_TASK_COMPLETED" : 0, "IMAGE_DATA_TYPE" : "image/jpeg", "DISTRICT": "district", - "SERVER_TIME_OUT" : 5000 + "SERVER_TIME_OUT" : 5000, + "PROJECT" : "project" }; diff --git a/module/project/templateTasks/helper.js b/module/project/templateTasks/helper.js index 082b4777..9aaf6cf9 100644 --- a/module/project/templateTasks/helper.js +++ b/module/project/templateTasks/helper.js @@ -16,6 +16,7 @@ const learningResourcesHelper = require(MODULES_BASE_PATH + "/learningResources/ const surveyService = require(GENERICS_FILES_PATH + "/services/survey"); const projectTemplateTaskQueries = require(DB_QUERY_BASE_PATH + "/projectTemplateTask"); const projectTemplateQueries = require(DB_QUERY_BASE_PATH + "/projectTemplates"); +const solutionsQueries = require(DB_QUERY_BASE_PATH + "/solutions"); module.exports = class ProjectTemplateTasksHelper { @@ -39,11 +40,8 @@ module.exports = class ProjectTemplateTasksHelper { let solutionIds = []; let systemId = false; let solutionExists = false; - csvData.forEach(data => { - let parsedData = UTILS.valueParser(data); - if( parsedData._SYSTEM_ID ) { taskIds.push(parsedData._SYSTEM_ID); systemId = true; @@ -376,6 +374,30 @@ module.exports = class ProjectTemplateTasksHelper { } } + //update solution project key + if ( taskData.type == CONSTANTS.common.OBSERVATION && + taskData.solutionDetails && + taskData.solutionDetails._id + ) { + + let updateSolutionObj = { + "$set" : {} + }; + + updateSolutionObj["$set"]["referenceFrom"] = CONSTANTS.common.PROJECT; + updateSolutionObj["$set"]["project"] = { + _id: template._id.toString(), + taskId: taskData._id.toString() + }; + + await solutionsQueries.updateSolutionDocument + ( + { _id : taskData.solutionDetails._id }, + updateSolutionObj + ) + } + + //update project template await projectTemplateQueries.updateProjectTemplateDocument ( { _id : template._id }, diff --git a/module/userProjects/helper.js b/module/userProjects/helper.js index 64fdb1c7..b1a6f0ee 100644 --- a/module/userProjects/helper.js +++ b/module/userProjects/helper.js @@ -2901,23 +2901,6 @@ function _observationDetails(observationData, userRoleAndProfileInformation = {} } else { - let solutionUpdated = - await surveyService.updateSolution( - observationData.token, - { - project: observationData.project, - referenceFrom: "project" - }, - observationData.solutionDetails.externalId - ); - - if (!solutionUpdated.success) { - throw { - status: HTTP_STATUS_CODE['bad_request'].status, - message: CONSTANTS.apiResponses.SOLUTION_NOT_UPDATED - } - } - let startDate = new Date(); let endDate = new Date(); endDate.setFullYear(endDate.getFullYear() + 1);