Merge branch 'develop' of code-repo.d4science.org:MaDgIK/openaire-library into develop

This commit is contained in:
Konstantinos Triantafyllou 2023-11-30 23:03:46 +02:00
commit 5eed3ce431
7 changed files with 62 additions and 23 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

@ -20,8 +20,7 @@ export class SearchSortingComponent {
@Input() entityType: string = '';
@Output() sortByChange = new EventEmitter();
public options: Option[];
private generalOptions = properties.environment != "production" ?
[
private generalOptions = [
{value: '', label: 'Relevance'},
{value: 'resultdateofacceptance,descending', label: 'Date (most recent)'},
{value: 'resultdateofacceptance,ascending', label: 'Date (least recent)'},
@ -29,11 +28,6 @@ export class SearchSortingComponent {
{value: 'popularity,descending', label: 'Popularity'},
{value: 'influence,descending', label: 'Influence'},
{value: 'impulse,descending', label: 'Impulse'}
] :
[
{value: '', label: 'Relevance'},
{value: 'resultdateofacceptance,descending', label: 'Date (most recent)'},
{value: 'resultdateofacceptance,ascending', label: 'Date (least recent)'}
];
private communityOptions = [
{value: '', label: 'Title'},

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
}

View File

@ -31,15 +31,15 @@ declare var UIkit: any;
<ng-content></ng-content>
</div>
<div *ngIf="(choice || okButton || cancelButton) && alertFooter" class="uk-modal-footer">
<div class="uk-grid uk-flex uk-flex-middle" uk-grid>
<div class="uk-grid uk-flex uk-flex-middle uk-margin-remove-left" uk-grid>
<label *ngIf="choice" class="uk-width-expand">
<input type="checkbox" [(ngModel)]="select">
<span class="uk-margin-small-left">Don't show this message again</span>
</label>
<div [ngClass]="(choice)?'uk-width-auto':'uk-width-1-1'">
<div class="uk-width-1-1" [ngClass]="(previousButton && (cancelButton || okButton)) ? 'uk-flex uk-flex-between uk-grid' : ''">
<div *ngIf="previousButton" class="uk-flex-left">
<button class="uk-button uk-button-default uk-margin-small-left"
<div [ngClass]="(choice)?'uk-width-auto':'uk-width-1-1 uk-padding-remove-horizontal'">
<div class="uk-width-1-1" [ngClass]="(previousButton && (cancelButton || okButton)) ? 'uk-flex uk-flex-between uk-grid uk-margin-remove-left' : ''">
<div *ngIf="previousButton" class="uk-flex-left uk-padding-remove-horizontal">
<button class="uk-button uk-button-default"
(click)="previous()">{{previousButtonText}}</button>
</div>
<div class="uk-flex-right uk-grid uk-grid-small" uk-grid>