[develop | DONE | CHANGED]: numbers.component.ts: Added in Numbers field "mergedFundersSize", and on init method call refine query for research products (results), to merge refine queries of research products and projects and set the mergedFundersSize (all funders that have research products, or have >1 project).
This commit is contained in:
parent
7cd9516493
commit
fa61b8bef4
|
@ -18,6 +18,7 @@ export interface Numbers {
|
|||
softwareSize?: NumberSize;
|
||||
otherSize?: NumberSize;
|
||||
fundersSize?: NumberSize;
|
||||
mergedFundersSize?: NumberSize;
|
||||
projectsSize?: NumberSize;
|
||||
datasourcesSize?: NumberSize;
|
||||
organizationsSize?: NumberSize;
|
||||
|
@ -89,6 +90,9 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
this.refineValue = refineValue;
|
||||
}
|
||||
let refineParams = (this.refineValue) ? ('&fq=' + this.refineValue) : null;
|
||||
|
||||
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,
|
||||
|
@ -98,7 +102,8 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
(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
|
||||
(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]);
|
||||
|
@ -123,6 +128,15 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
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]);
|
||||
|
@ -130,7 +144,17 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
if (data[8] && data[8] > 0) {
|
||||
this.numbers.organizationsSize = NumberUtils.roundNumber(data[8]);
|
||||
}
|
||||
this.results.emit(this.numbers);
|
||||
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.results.emit(this.numbers);
|
||||
}, err => {
|
||||
this.handleError('Error getting numbers', err);
|
||||
}));
|
||||
|
|
Loading…
Reference in New Issue