Merge remote-tracking branch 'origin/develop' into angular-16-irish-monitor

This commit is contained in:
Konstantinos Triantafyllou 2023-11-30 23:04:07 +02:00
commit 7b79146f12
5 changed files with 56 additions and 11 deletions

View File

@ -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;

View File

@ -1251,7 +1251,7 @@
</thead>
<tbody>
<tr *ngFor="let datasource of resultLandingInfo.measure.countsPerDatasource">
<td class="uk-text-truncate"><a [routerLink]="properties.searchLinkToDataProvider.split('?')[0]" [queryParams]="{'datasourceId': datasource.datasourceId}">{{datasource.datasourceId}}</a></td>
<td class="uk-text-truncate"><a [routerLink]="properties.searchLinkToDataProvider.split('?')[0]" [queryParams]="{'datasourceId': datasource.datasourceId}">{{datasource.datasourceName}}</a></td>
<td class="uk-text-center">{{datasource.views}}</td>
<td class="uk-text-center">{{datasource.downloads}}</td>
</tr>

View File

@ -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 => <any> 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[]=["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);
}
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{

View File

@ -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,
@ -96,9 +100,10 @@ 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
(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);
}));

View File

@ -49,7 +49,7 @@ export interface Measure {
export interface MetricPerDatasource {
datasourceId: string,
// datasourceName: string,
datasourceName: string,
views: number,
downloads: number
}