[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,87 +93,74 @@ export class NumbersComponent implements OnInit, OnDestroy {
}
let refineParams = (this.refineValue) ? ('&fq=' + this.refineValue) : null;
// let mergedFundersSet = new Set<string>();
// 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 => {}));
// 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 => {}));
// 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 => {}));
// this.subs.push(((getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty).subscribe(x => {}));
// 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);
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);
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);
}
), err => {
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) {
@ -212,6 +199,7 @@ export class NumbersComponent implements OnInit, OnDestroy {
this.handleError('Error getting numbers', err);
}));
}
}
ngOnDestroy() {
this.subs.forEach(sub => {