[Monitor]: Restrict calls of number with the same source and url to once.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor@57382 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
c10448c837
commit
0c762c6893
|
@ -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<string, number[]> = new Map<string, number[]>();
|
||||
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) {
|
||||
|
|
Loading…
Reference in New Issue