[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:
parent
b89278af70
commit
f55107b8d5
|
@ -93,117 +93,104 @@ 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) {
|
||||
if (data) {
|
||||
if (data.hasOwnProperty("publications") && data['publications'] > 0) {
|
||||
this.numbers.publicationsSize = NumberUtils.roundNumber(data['publications']);
|
||||
}
|
||||
if(data.hasOwnProperty("datasets") && data['datasets'] > 0) {
|
||||
if (data.hasOwnProperty("datasets") && data['datasets'] > 0) {
|
||||
this.numbers.datasetsSize = NumberUtils.roundNumber(data['datasets']);
|
||||
}
|
||||
if(data.hasOwnProperty("datasetsInterlinked") && data['datasetsInterlinked'] > 0) {
|
||||
if (data.hasOwnProperty("datasetsInterlinked") && data['datasetsInterlinked'] > 0) {
|
||||
this.numbers.datasetsLinkedSize = NumberUtils.roundNumber(data['datasetsInterlinked']);
|
||||
}
|
||||
if(data.hasOwnProperty("software") && data['software'] > 0) {
|
||||
if (data.hasOwnProperty("software") && data['software'] > 0) {
|
||||
this.numbers.softwareSize = NumberUtils.roundNumber(data['software']);
|
||||
}
|
||||
if(data.hasOwnProperty("softwareInterlinked") && data['softwareInterlinked'] > 0) {
|
||||
if (data.hasOwnProperty("softwareInterlinked") && data['softwareInterlinked'] > 0) {
|
||||
this.numbers.softwareLinkedSize = NumberUtils.roundNumber(data['softwareInterlinked']);
|
||||
}
|
||||
if(data.hasOwnProperty("other") && data['other'] > 0) {
|
||||
if (data.hasOwnProperty("other") && data['other'] > 0) {
|
||||
this.numbers.otherSize = NumberUtils.roundNumber(data['other']);
|
||||
}
|
||||
if(data.hasOwnProperty("projects") && data['projects'] > 0) {
|
||||
if (data.hasOwnProperty("projects") && data['projects'] > 0) {
|
||||
this.numbers.projectsSize = NumberUtils.roundNumber(data['projects']);
|
||||
}
|
||||
if(data.hasOwnProperty("funders") && data['funders'] > 0) {
|
||||
if (data.hasOwnProperty("funders") && data['funders'] > 0) {
|
||||
this.numbers.mergedFundersSize = NumberUtils.roundNumber(data['funders']);
|
||||
}
|
||||
if(data.hasOwnProperty("datasources") && data['datasources'] > 0) {
|
||||
if (data.hasOwnProperty("datasources") && data['datasources'] > 0) {
|
||||
this.numbers.datasourcesSize = NumberUtils.roundNumber(data['datasources']);
|
||||
}
|
||||
if(data.hasOwnProperty("organizations") && data['organizations'] > 0) {
|
||||
if (data.hasOwnProperty("organizations") && data['organizations'] > 0) {
|
||||
this.numbers.organizationsSize = NumberUtils.roundNumber(data['organizations']);
|
||||
}
|
||||
}
|
||||
|
@ -212,6 +199,7 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
this.handleError('Error getting numbers', err);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subs.forEach(sub => {
|
||||
|
|
Loading…
Reference in New Issue