Skip to content

Commit

Permalink
Merge pull request #101 from priyanka-TL/release4.10
Browse files Browse the repository at this point in the history
solution project update fix
  • Loading branch information
aks30 authored Sep 7, 2022
2 parents 9f2ba1e + 199659e commit ffa39bb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
3 changes: 2 additions & 1 deletion generics/constants/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
};
28 changes: 25 additions & 3 deletions module/project/templateTasks/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -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;
Expand Down Expand Up @@ -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 },
Expand Down
17 changes: 0 additions & 17 deletions module/userProjects/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ffa39bb

Please sign in to comment.