diff --git a/src/app/monitor/monitor.component.ts b/src/app/monitor/monitor.component.ts index ecadc9d..8e95003 100644 --- a/src/app/monitor/monitor.component.ts +++ b/src/app/monitor/monitor.component.ts @@ -14,6 +14,7 @@ import {StakeholderService} from "../services/stakeholder.service"; import {Category, IndicatorPath, Stakeholder, SubCategory, Topic} from "../utils/entities/stakeholder"; import {MenuItem, RootMenuItem, SideMenuItem} from "../openaireLibrary/sharedComponents/menu"; import {StatisticsService} from "../utils/services/statistics.service"; +import {response} from "express"; @Component({ selector: 'monitor', @@ -162,13 +163,26 @@ export class MonitorComponent { } private setIndicators() { + let urls: Map = new Map(); this.activeSubCategory.numbers.forEach((number, index) => { - this.statisticsService.getNumbers(number.indicatorPaths[0].source, number.indicatorPaths[0].url).subscribe(response => { - number.indicatorPaths[0].jsonPath.forEach(jsonPath => { - response = response[jsonPath]; + if(number.isActive && number.isPublic) { + const pair = JSON.stringify([number.indicatorPaths[0].source, number.indicatorPaths[0].url]); + const indexes = urls.get(pair) ? urls.get(pair) : []; + indexes.push(index); + urls.set(pair, indexes); + } + }); + urls.forEach((indexes, pair) => { + pair = JSON.parse(pair); + this.statisticsService.getNumbers(pair[0], pair[1]).subscribe( response => { + indexes.forEach( index => { + let result = JSON.parse(JSON.stringify(response)); + this.activeSubCategory.numbers[index].indicatorPaths[0].jsonPath.forEach(jsonPath => { + result = result[jsonPath]; + }); + this.numberResults.set(index, result); }); - this.numberResults.set(index, response); - }); + }) }); this.activeSubCategory.charts.forEach((chart, index) => { if (chart.indicatorPaths.length > 0) {