Fix script for add funding stream in default msca

This commit is contained in:
Konstantinos Triantafyllou 2023-06-09 13:35:03 +03:00
parent 273858cc2c
commit f246e4d6b8
1 changed files with 16 additions and 13 deletions

View File

@ -444,19 +444,22 @@ function addFundingStreamInDefaultMSCA() {
var section = db.section.findOne({"_id": ObjectId(chart)});
section.indicators.forEach((indicator) => {
var indicatorObject = db.indicator.findOne({"_id": ObjectId(indicator)});
if(indicatorObject.indicatorPaths[0] && indicatorObject.indicatorPaths[0].chartObject) {
var json = JSON.parse(indicatorObject.indicatorPaths[0].chartObject);
if(json.chartDescription && json.chartDescription.queries && json.chartDescription.queries.length > 0) {
json.chartDescription.queries.forEach(query => {
if(query.query && query.query.filters && query.query.filters.length > 0) {
query.query.filters.forEach(filter => {
filter = addFundingLevelInFilters(filter);
})
}
});
indicatorObject.indicatorPaths[0].chartObject = JSON.stringify(json);
db.indicator.save(indicatorObject);
}
if(indicatorObject.indicatorPaths[0].parameters) {
indicatorObject.indicatorPaths[0].parameters['index_shortName'] = stakeholder.index_shortName.toLowerCase();
if (indicatorObject.indicatorPaths[0] && indicatorObject.indicatorPaths[0].chartObject) {
var json = JSON.parse(indicatorObject.indicatorPaths[0].chartObject);
if (json.chartDescription && json.chartDescription.queries && json.chartDescription.queries.length > 0) {
json.chartDescription.queries.forEach(query => {
if (query.query && query.query.filters && query.query.filters.length > 0) {
query.query.filters.forEach(filter => {
filter = addFundingLevelInFilters(filter);
});
}
});
indicatorObject.indicatorPaths[0].chartObject = JSON.stringify(json);
db.indicator.save(indicatorObject);
}
}
}
});
});