[develop | DONE | FIXED]: numbers.component.ts: [BUG FIX] Call "groupedRequestsService.home()" when no refineParams, otherwise (e.g. in aggregator), zip multiple queries.

This commit is contained in:
Konstantina Galouni 2024-02-08 18:00:40 +02:00
parent b89278af70
commit f55107b8d5
1 changed files with 102 additions and 114 deletions

View File

@ -93,124 +93,112 @@ export class NumbersComponent implements OnInit, OnDestroy {
} }
let refineParams = (this.refineValue) ? ('&fq=' + this.refineValue) : null; let refineParams = (this.refineValue) ? ('&fq=' + this.refineValue) : null;
// let mergedFundersSet = new Set<string>(); if (refineParams) {
let mergedFundersSet = new Set<string>();
this.subs.push(zip(
(getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty,
(getDatasets) ? this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, refineParams) : this.empty,
(getDatasetsLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties) : this.empty,
(getSoftware) ? this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, refineParams) : this.empty,
(getSoftwareLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties) : this.empty,
(getOther) ? this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, refineParams) : this.empty,
(getProjects) ? this.refineFieldResultsService.getAllRefineFieldResultsByFieldName('funder', 'project', this.properties, refineParams) : this.empty,
(getDataProviders) ? this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, refineParams) : this.empty,
(getOrganizations) ? this._searchOrganizationsService.numOfSearchOrganizations2('', this.properties, refineParams) : this.empty,
(getPublications && getDatasets && getSoftware && getOther) ? this.refineFieldResultsService.getAllRefineFieldResultsByFieldName('relfunder', 'result', this.properties, refineParams) : this.empty,
).subscribe((data: any[]) => {
if (data[0] && data[0] > 0) {
this.numbers.publicationsSize = NumberUtils.roundNumber(data[0]);
}
if (data[1] && data[1] > 0) {
this.numbers.datasetsSize = NumberUtils.roundNumber(data[1]);
}
if (data[2] && data[2] > 0) {
this.numbers.datasetsLinkedSize = NumberUtils.roundNumber(data[2]);
}
if (data[3] && data[3] > 0) {
this.numbers.softwareSize = NumberUtils.roundNumber(data[3]);
}
if (data[4] && data[4] > 0) {
this.numbers.softwareLinkedSize = NumberUtils.roundNumber(data[4]);
}
if (data[5] && data[5] > 0) {
this.numbers.otherSize = NumberUtils.roundNumber(data[5]);
}
if (data[6][0] && data[6][0] > 0) {
this.numbers.projectsSize = NumberUtils.roundNumber(data[6][0]);
}
if (data[6][1] && data[6][1].length > 0 && data[6][1][0].filterId == 'funder' && data[6][1][0].values) {
this.numbers.fundersSize = NumberUtils.roundNumber(data[6][1][0].values.length);
// this.subs.push(((getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty).subscribe(x => {})); let queriedFunders = data[6][1][0].values;
// this.subs.push(((getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty).subscribe(x => {})); queriedFunders.forEach(queriedFunder => {
// this.subs.push(((getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty).subscribe(x => {})); if (+queriedFunder.number > 1) {
// this.subs.push(((getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty).subscribe(x => {})); if (!mergedFundersSet.has(queriedFunder.id)) {
// this.subs.push(((getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty).subscribe(x => {})); mergedFundersSet.add(queriedFunder.id);
// this.subs.push(((getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty).subscribe(x => {})); }
// this.subs.push(((getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty).subscribe(x => {})); }
});
}
if (data[7] && data[7] > 0) {
this.numbers.datasourcesSize = NumberUtils.roundNumber(data[7]);
}
if (data[8] && data[8] > 0) {
this.numbers.organizationsSize = NumberUtils.roundNumber(data[8]);
}
if (data[9][1] && data[9][1].length > 0 && data[9][1][0].filterId == 'relfunder' && data[9][1][0].values) {
let queriedFunders = data[9][1][0].values;
queriedFunders.forEach(queriedFunder => {
if (!mergedFundersSet.has(queriedFunder.id)) {
mergedFundersSet.add(queriedFunder.id);
}
});
}
this.numbers.mergedFundersSize = NumberUtils.roundNumber(mergedFundersSet.size);
// this.subs.push(zip(
// // (getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty,
// // (getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty,
// // (getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty,
// // (getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty,
// // (getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty,
// // (getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty,
// (getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty,
// (getDatasets) ? this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, refineParams) : this.empty,
// (getDatasetsLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties) : this.empty,
// (getSoftware) ? this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, refineParams) : this.empty,
// (getSoftwareLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties) : this.empty,
// (getOther) ? this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, refineParams) : this.empty,
// (getProjects) ? this.refineFieldResultsService.getAllRefineFieldResultsByFieldName('funder', 'project', this.properties, refineParams) : this.empty,
// (getDataProviders) ? this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, refineParams) : this.empty,
// (getOrganizations) ? this._searchOrganizationsService.numOfSearchOrganizations2('', this.properties, refineParams) : this.empty,
// (getPublications && getDatasets && getSoftware && getOther) ? this.refineFieldResultsService.getAllRefineFieldResultsByFieldName('relfunder', 'result', this.properties, refineParams) : this.empty,
// ).subscribe((data: any[]) => {
// if (data[0] && data[0] > 0) {
// this.numbers.publicationsSize = NumberUtils.roundNumber(data[0]);
// }
// if (data[1] && data[1] > 0) {
// this.numbers.datasetsSize = NumberUtils.roundNumber(data[1]);
// }
// if (data[2] && data[2] > 0) {
// this.numbers.datasetsLinkedSize = NumberUtils.roundNumber(data[2]);
// }
// if (data[3] && data[3] > 0) {
// this.numbers.softwareSize = NumberUtils.roundNumber(data[3]);
// }
// if (data[4] && data[4] > 0) {
// this.numbers.softwareLinkedSize = NumberUtils.roundNumber(data[4]);
// }
// if (data[5] && data[5] > 0) {
// this.numbers.otherSize = NumberUtils.roundNumber(data[5]);
// }
// if (data[6][0] && data[6][0] > 0) {
// this.numbers.projectsSize = NumberUtils.roundNumber(data[6][0]);
// }
// if (data[6][1] && data[6][1].length > 0 && data[6][1][0].filterId == 'funder' && data[6][1][0].values) {
// this.numbers.fundersSize = NumberUtils.roundNumber(data[6][1][0].values.length);
//
// let queriedFunders = data[6][1][0].values;
// queriedFunders.forEach(queriedFunder => {
// if(+queriedFunder.number > 1) {
// if (!mergedFundersSet.has(queriedFunder.id)) {
// mergedFundersSet.add(queriedFunder.id);
// }
// }
// });
// }
// if (data[7] && data[7] > 0) {
// this.numbers.datasourcesSize = NumberUtils.roundNumber(data[7]);
// }
// if (data[8] && data[8] > 0) {
// this.numbers.organizationsSize = NumberUtils.roundNumber(data[8]);
// }
// if (data[9][1] && data[9][1].length > 0 && data[9][1][0].filterId == 'relfunder' && data[9][1][0].values) {
// let queriedFunders = data[9][1][0].values;
// queriedFunders.forEach(queriedFunder => {
// if (!mergedFundersSet.has(queriedFunder.id)) {
// mergedFundersSet.add(queriedFunder.id);
// }
// });
// }
//
// this.numbers.mergedFundersSize = NumberUtils.roundNumber(mergedFundersSet.size);
this.subs.push(this.groupedRequestsService.home().subscribe((data: any[]) => {
if(data) {
if(data.hasOwnProperty("publications") && data['publications'] > 0) {
this.numbers.publicationsSize = NumberUtils.roundNumber(data['publications']);
} }
if(data.hasOwnProperty("datasets") && data['datasets'] > 0) { ), err => {
this.numbers.datasetsSize = NumberUtils.roundNumber(data['datasets']); this.handleError('Error getting numbers', err);
});
} else {
this.subs.push(this.groupedRequestsService.home().subscribe((data: any[]) => {
if (data) {
if (data.hasOwnProperty("publications") && data['publications'] > 0) {
this.numbers.publicationsSize = NumberUtils.roundNumber(data['publications']);
}
if (data.hasOwnProperty("datasets") && data['datasets'] > 0) {
this.numbers.datasetsSize = NumberUtils.roundNumber(data['datasets']);
}
if (data.hasOwnProperty("datasetsInterlinked") && data['datasetsInterlinked'] > 0) {
this.numbers.datasetsLinkedSize = NumberUtils.roundNumber(data['datasetsInterlinked']);
}
if (data.hasOwnProperty("software") && data['software'] > 0) {
this.numbers.softwareSize = NumberUtils.roundNumber(data['software']);
}
if (data.hasOwnProperty("softwareInterlinked") && data['softwareInterlinked'] > 0) {
this.numbers.softwareLinkedSize = NumberUtils.roundNumber(data['softwareInterlinked']);
}
if (data.hasOwnProperty("other") && data['other'] > 0) {
this.numbers.otherSize = NumberUtils.roundNumber(data['other']);
}
if (data.hasOwnProperty("projects") && data['projects'] > 0) {
this.numbers.projectsSize = NumberUtils.roundNumber(data['projects']);
}
if (data.hasOwnProperty("funders") && data['funders'] > 0) {
this.numbers.mergedFundersSize = NumberUtils.roundNumber(data['funders']);
}
if (data.hasOwnProperty("datasources") && data['datasources'] > 0) {
this.numbers.datasourcesSize = NumberUtils.roundNumber(data['datasources']);
}
if (data.hasOwnProperty("organizations") && data['organizations'] > 0) {
this.numbers.organizationsSize = NumberUtils.roundNumber(data['organizations']);
}
} }
if(data.hasOwnProperty("datasetsInterlinked") && data['datasetsInterlinked'] > 0) { this.results.emit(this.numbers);
this.numbers.datasetsLinkedSize = NumberUtils.roundNumber(data['datasetsInterlinked']); }, err => {
} this.handleError('Error getting numbers', err);
if(data.hasOwnProperty("software") && data['software'] > 0) { }));
this.numbers.softwareSize = NumberUtils.roundNumber(data['software']); }
}
if(data.hasOwnProperty("softwareInterlinked") && data['softwareInterlinked'] > 0) {
this.numbers.softwareLinkedSize = NumberUtils.roundNumber(data['softwareInterlinked']);
}
if(data.hasOwnProperty("other") && data['other'] > 0) {
this.numbers.otherSize = NumberUtils.roundNumber(data['other']);
}
if(data.hasOwnProperty("projects") && data['projects'] > 0) {
this.numbers.projectsSize = NumberUtils.roundNumber(data['projects']);
}
if(data.hasOwnProperty("funders") && data['funders'] > 0) {
this.numbers.mergedFundersSize = NumberUtils.roundNumber(data['funders']);
}
if(data.hasOwnProperty("datasources") && data['datasources'] > 0) {
this.numbers.datasourcesSize = NumberUtils.roundNumber(data['datasources']);
}
if(data.hasOwnProperty("organizations") && data['organizations'] > 0) {
this.numbers.organizationsSize = NumberUtils.roundNumber(data['organizations']);
}
}
this.results.emit(this.numbers);
}, err => {
this.handleError('Error getting numbers', err);
}));
} }
ngOnDestroy() { ngOnDestroy() {