From ff34511a9c4ce83a160e71ec58cde398aee12352 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 24 Nov 2023 11:44:23 +0200 Subject: [PATCH 1/5] [develop | DONE | CHANGED]: refineFieldResults.service.ts: Added method "getAllRefineFieldResultsByFieldName()" to get all values of a specific refine field (not just first 100) | In method "getRefineFieldResultsByFieldName()" changed key:string to keys:string[] to be able to define multiple fields to query for all their values - creted helper method "fieldIncludesAnyOfTheKeywords()". --- services/refineFieldResults.service.ts | 29 ++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/services/refineFieldResults.service.ts b/services/refineFieldResults.service.ts index d40819ab..157556c5 100644 --- a/services/refineFieldResults.service.ts +++ b/services/refineFieldResults.service.ts @@ -26,11 +26,32 @@ export class RefineFieldResultsService { .pipe(map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],fields, entityName)])); } - getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{ - let key:string="fundinglevel"; - let link = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +(fieldName.toString().indexOf(key)!=-1?('&sf='+fieldName):'')+ "&format=json"; - return this.getField(link,fieldName, properties); + getAllRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties, refineQuery:string=null):any{ + // let keys:string[]=["funder", "relfunder", "fundinglevel"]; + let url = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +('&sf='+fieldName)+ "&format=json"; + if(refineQuery!= null && refineQuery != '' ) { + url += refineQuery; + } + return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url) + //.map(res => res.json()) + + .pipe(map(res => [res['meta'].total, RefineResultsUtils.parse(res['refineResults'],[fieldName], entityName)])); + } + + getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{ + let keys:string[]=["fundinglevel"]; + let link = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +(this.fieldIncludesAnyOfTheKeywords(fieldName, keys)?('&sf='+fieldName):'')+ "&format=json"; + return this.getField(link,fieldName, properties); + } + + fieldIncludesAnyOfTheKeywords(field: string, keywords: string[]) { + for(let keyword of keywords) { + if(field.toString().indexOf(keyword)!=-1) { + return true; + } + } + return false; } getField (link:string,fieldName:string, properties:EnvProperties):any{ From 54e01815609b3978f430cb036edd3461971c5d90 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 24 Nov 2023 13:18:22 +0200 Subject: [PATCH 2/5] [develop | DONE | FIXED] numbers.component.ts: Updated method called in refine query to get funders of projects from "getRefineFieldsResultsByEntityName()" to "getAllRefineFieldResultsByFieldName()" to be able to get more than 100 funders each time. --- sharedComponents/numbers/numbers.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sharedComponents/numbers/numbers.component.ts b/sharedComponents/numbers/numbers.component.ts index cb163c7d..0429a466 100644 --- a/sharedComponents/numbers/numbers.component.ts +++ b/sharedComponents/numbers/numbers.component.ts @@ -96,7 +96,7 @@ export class NumbersComponent implements OnInit, OnDestroy { (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.getRefineFieldsResultsByEntityName(['funder'], 'project', 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 ).subscribe((data: any[]) => { From 7cd951649314c18be820f731d1eed08bcfa3877f Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 24 Nov 2023 16:57:35 +0200 Subject: [PATCH 3/5] [develop | DONE | CHANGED]: refineFieldResults.service.ts: In method "getRefineFieldResultsByFieldName()" added in keys "funder", to get (refine query) all funders for research products and projects in autocomplete (advanced) search. --- services/refineFieldResults.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/refineFieldResults.service.ts b/services/refineFieldResults.service.ts index 157556c5..f43771dd 100644 --- a/services/refineFieldResults.service.ts +++ b/services/refineFieldResults.service.ts @@ -40,7 +40,7 @@ export class RefineFieldResultsService { } getRefineFieldResultsByFieldName(fieldName:string, entityName:string, properties:EnvProperties):any{ - let keys:string[]=["fundinglevel"]; + let keys:string[]=["funder", "fundinglevel"]; // this covers funder, relfunder, funding stream fields and funding level fields let link = properties.searchAPIURLLAst +this.getSearchAPIURLForEntity(entityName)+"?fields="+fieldName +(this.fieldIncludesAnyOfTheKeywords(fieldName, keys)?('&sf='+fieldName):'')+ "&format=json"; return this.getField(link,fieldName, properties); } From fa61b8bef431b03eca1092fe05ab16611e3233ae Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Fri, 24 Nov 2023 16:59:55 +0200 Subject: [PATCH 4/5] [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). --- sharedComponents/numbers/numbers.component.ts | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/sharedComponents/numbers/numbers.component.ts b/sharedComponents/numbers/numbers.component.ts index 0429a466..bd83f769 100644 --- a/sharedComponents/numbers/numbers.component.ts +++ b/sharedComponents/numbers/numbers.component.ts @@ -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(); + 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); })); From c7c1aec26ea7ff3decda4675a7bdb0e6ea83a4ae Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 27 Nov 2023 18:10:37 +0200 Subject: [PATCH 5/5] [develop | DONE | CHANGED]: Updated parsing and display for usage counts per data source to show datasource names. 1. resultLandingInfo.ts: Added field datasourceName: string in interface MetricPerDatasource. 2. parsingFunctions.class.ts: In method "parseMeasures()", updated parsing for usage counts per data source (countsPerDatasource) to parse datasourceId and datasourceName from datasource field of response (split by ||). 3. resultLanding.component.html: On display of countsPerDatasource in table, show datasource names. --- landingPages/landing-utils/parsingFunctions.class.ts | 4 ++-- landingPages/result/resultLanding.component.html | 2 +- utils/entities/resultLandingInfo.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/landingPages/landing-utils/parsingFunctions.class.ts b/landingPages/landing-utils/parsingFunctions.class.ts index a34ba066..846de4a9 100644 --- a/landingPages/landing-utils/parsingFunctions.class.ts +++ b/landingPages/landing-utils/parsingFunctions.class.ts @@ -894,7 +894,7 @@ export class ParsingFunctions { countsPerDatasource[datasourcePosition.get(element.datasource)].views = element.count; } else { datasourcePosition.set(element.datasource, countsPerDatasource.length); - countsPerDatasource.push({"datasourceId": element.datasource, "views": element.count, "downloads": 0}) + countsPerDatasource.push({"datasourceId": element.datasource.split("||")[0], "datasourceName": element.datasource.split("||")[1], "views": element.count, "downloads": 0}) } } // measure.views = element.count; @@ -907,7 +907,7 @@ export class ParsingFunctions { countsPerDatasource[datasourcePosition.get(element.datasource)].downloads = element.count; } else { datasourcePosition.set(element.datasource, countsPerDatasource.length); - countsPerDatasource.push({"datasourceId": element.datasource, "views": 0, "downloads": element.count}) + countsPerDatasource.push({"datasourceId": element.datasource.split("||")[0], "datasourceName": element.datasource.split("||")[1], "views": 0, "downloads": element.count}) } } // measure.downloads = element.count; diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index dd683993..7d6a9ccd 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -1251,7 +1251,7 @@ - {{datasource.datasourceId}} + {{datasource.datasourceName}} {{datasource.views}} {{datasource.downloads}} diff --git a/utils/entities/resultLandingInfo.ts b/utils/entities/resultLandingInfo.ts index 8a45393b..1e2f7740 100644 --- a/utils/entities/resultLandingInfo.ts +++ b/utils/entities/resultLandingInfo.ts @@ -49,7 +49,7 @@ export interface Measure { export interface MetricPerDatasource { datasourceId: string, - // datasourceName: string, + datasourceName: string, views: number, downloads: number }