Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.
Merged
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
12 changes: 8 additions & 4 deletions annotation-service/services/dataSet-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,26 @@ async function updateDataset(req) {

}

async function updateDatasetProjectInfo(dataSetName, projectName, operation) {
async function updateDatasetProjectInfo(dataSetName, projectName, operation, newProjectName) {

const condistion = {dataSetName: dataSetName};
const condition = {dataSetName: dataSetName};
const options = { new: true, upsert: true };
let update = {};

if (OPERATION.ADD == operation) {
update = { $push: { projects: projectName } }
update = { $addToSet: { projects: projectName } }
}else if (OPERATION.DELETE == operation) {
update = { $pull: { projects: projectName } }
}else if (OPERATION.UPDATE == operation) {
condition['projects'] = projectName
update = { $set: {"projects.$": newProjectName} }

}else{
throw MESSAGE.VALIDATATION_OPERATION;
}

console.log(`[ DATASET ] Service updateDatasetProjectInfo`);
return mongoDb.findOneAndUpdate(DataSetModel, condistion, update, options);
return mongoDb.findOneAndUpdate(DataSetModel, condition, update, options);

}

Expand Down
13 changes: 9 additions & 4 deletions annotation-service/services/project.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ async function updateProject(req) {
const srsCondition = { projectName: req.body.previousPname };
const srsDoc = { projectName: req.body.pname };
await mongoDb.updateManyByConditions(mp.model, srsCondition, srsDoc);
//update dataset maped projectName
for (const dsName of _.union(mp.project.selectedDataset)) {
await require('./dataSet-service').updateDatasetProjectInfo(dsName, req.body.previousPname, OPERATION.UPDATE, req.body.pname);
}

}

const projectInfo = mp.project;
Expand Down Expand Up @@ -1054,20 +1059,20 @@ async function getProjectsTextTabular(email) {
}

async function updateProjectDatasetInfo(projectName, datasetName, operation) {
const condistion = {projectName: projectName};
const condition = {projectName: projectName};
const options = { new: true, upsert: true };
let update = {};

if (OPERATION.ADD == operation) {
update = { $push: { selectedDataset: datasetName } };
update = { $addToSet: { selectedDataset: datasetName } };
}else if (OPERATION.DELETE == operation) {
update = { $pull: { selectedDataset: datasetName } };
}else{
throw MESSAGE.VALIDATATION_OPERATION;
}

console.log(`[ DATASET ] Service updateProjectDatasetInfo`);
return mongoDb.findOneAndUpdate(ProjectModel, condistion, update, options);
console.log(`[ DATASET ] Service updateProjectDatasetInfo`, update);
return mongoDb.findOneAndUpdate(ProjectModel, condition, update, options);
}


Expand Down
4 changes: 2 additions & 2 deletions annotation-service/services/srs-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ async function appendSrsDataByCSVFile(req, originalHeaders, project) {
const update = {
$set: { appendSr: APPENDSR.DONE, updatedDate: Date.now() },
$inc: { totalCase: caseNum },
$push: { selectedDataset: req.body.selectedDataset }
$addToSet: { selectedDataset: req.body.selectedDataset }
};
await mongoDb.findOneAndUpdate(ProjectModel, conditions, update);
await updateDatasetProjectInfo(req.body.selectedDataset, req.body.pname, OPERATION.ADD);
Expand Down Expand Up @@ -690,7 +690,7 @@ async function appendSrsData(req) {
if (req.body.isFile == true || req.body.isFile == 'true') {
//file append
await imgImporter.execute(req, false);
update.$push = { selectedDataset: dataset };
update.$addToSet = { selectedDataset: dataset };
update.$inc = { totalCase: datasets[0].images.length };

} else {
Expand Down
2 changes: 1 addition & 1 deletion annotation-service/utils/logImporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async function execute(req, sendEmail, annotators, append) {
if (append) {

update.$set = { appendSr: APPENDSR.DONE };
update.$push = { selectedDataset: selectedDataset };
update.$addToSet = { selectedDataset: selectedDataset };

await projectService.updateAssinedCase(condition, totalCase, true);
}
Expand Down