diff --git a/pom.xml b/pom.xml index 393fcdd..fc073a8 100644 --- a/pom.xml +++ b/pom.xml @@ -26,7 +26,7 @@ eu.dnetlib uoa-monitor-service - 1.1.10 + 1.1.11 library diff --git a/scripts/2024-04-12.js b/scripts/2024-04-12.js new file mode 100644 index 0000000..d647135 --- /dev/null +++ b/scripts/2024-04-12.js @@ -0,0 +1,66 @@ +function deleteIndexParameters() { + var indicators = db.indicator.find(); + indicators.forEach(indicator => { + indicator.indicatorPaths.forEach(path => { + if(path.parameters) { + delete path.parameters['index_id']; + delete path.parameters['index_name']; + delete path.parameters['index_shortName']; + } + db.indicator.save(indicator); + }); + }) +} + +function convertProfilesToReferences() { + var defaultStakeholders = db.stakeholder.find({defaultId: null}); + defaultStakeholders.forEach(stakeholder => { + stakeholder.copy = false; + db.stakeholder.save(stakeholder); + }) + var stakeholders = db.stakeholder.find({ defaultId: { $exists: true, $ne: null } }); + stakeholders.forEach(stakeholder => { + stakeholder.copy = false; + stakeholder.topics.forEach(topicId => { + var topic = db.topic.findOne({_id: ObjectId(topicId)}); + topic.categories.forEach(categoryId => { + var category = db.category.findOne({_id: ObjectId(categoryId)}); + category.subCategories.forEach(subCategoryId => { + var subCategory = db.subCategory.findOne({_id: ObjectId(subCategoryId)}); + subCategory.numbers.forEach(sectionId => { + var section = db.section.findOne({_id: ObjectId(sectionId)}); + section.indicators.forEach(indicatorId => { + db.indicator.deleteOne({_id: ObjectId(indicatorId)}); + }); + db.section.deleteOne({_id: ObjectId(sectionId)}); + }); + subCategory.charts.forEach(sectionId => { + var section = db.section.findOne({_id: ObjectId(sectionId)}); + section.indicators.forEach(indicatorId => { + db.indicator.deleteOne({_id: ObjectId(indicatorId)}); + }); + db.section.deleteOne({_id: ObjectId(sectionId)}); + }); + db.subCategory.deleteOne({_id: ObjectId(subCategoryId)}); + }); + db.category.deleteOne({_id: ObjectId(categoryId)}); + }); + db.topic.deleteOne({_id: ObjectId(topicId)}); + }); + stakeholder.topics = []; + db.stakeholder.save(stakeholder); + }); +} + +print('topic: ' + db.topic.find({ defaultId: { $exists: true, $ne: null } }).count()); +print('category: ' + db.category.find({ defaultId: { $exists: true, $ne: null } }).count()); +print('subCategory: ' + db.subCategory.find({ defaultId: { $exists: true, $ne: null } }).count()); +print('Section: ' + db.section.find({ defaultId: { $exists: true, $ne: null } }).count()); +print('Indicator: ' + db.indicator.find({ defaultId: { $exists: true, $ne: null } }).count()); +convertProfilesToReferences(); +deleteIndexParameters(); +print('topic: ' + db.topic.find({ defaultId: { $exists: true, $ne: null } }).count()); +print('category: ' + db.category.find({ defaultId: { $exists: true, $ne: null } }).count()); +print('subCategory: ' + db.subCategory.find({ defaultId: { $exists: true, $ne: null } }).count()); +print('Section: ' + db.section.find({ defaultId: { $exists: true, $ne: null } }).count()); +print('Indicator: ' + db.indicator.find({ defaultId: { $exists: true, $ne: null } }).count()); diff --git a/scripts/datasourceProfile.js b/scripts/datasourceProfile.js deleted file mode 100644 index 5416bf9..0000000 --- a/scripts/datasourceProfile.js +++ /dev/null @@ -1,15 +0,0 @@ -function updateDatasourceIndicators() { - var indicators = db.indicator.find(); - indicators.forEach(indicator => { - indicator.indicatorPaths.forEach(path => { - if(path.chartObject && path.chartObject.includes('opendoar____::115f89503138416a242f40fb7d7f338e')) { - while(path.chartObject.includes('opendoar____::115f89503138416a242f40fb7d7f338e')) { - path.chartObject = path.chartObject.replace('opendoar____::115f89503138416a242f40fb7d7f338e', '((__index_id__))'); - } - db.indicator.save(indicator); - } - }); - }); -} - -updateDatasourceIndicators();