Skip to content

Commit

Permalink
Merge pull request #1882 from CSCfi/CSCTTV-4092
Browse files Browse the repository at this point in the history
fix persons sorts and add default sort by updated timestamp
  • Loading branch information
konolak authored Nov 26, 2024
2 parents 9959edd + 486e6d9 commit b77d72d
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 20 deletions.
10 changes: 6 additions & 4 deletions src/app/portal/models/person/person.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export class Person {
public keywords: string,
public collaboration: string[],
public uniqueDataSources: any,
public orcidLink?: string
public orcidLink?: string,
public updated?: string
) {}
}

Expand Down Expand Up @@ -147,11 +148,11 @@ export class PersonAdapter implements Adapter<Person> {
const fieldsOfScience = 'Placeholder';

const keywords = data.personal.keywords
.map((keyword) => keyword.value)
.map((keyword) => keyword.value).sort()
.join(', ');

const uniqueDataSources = data.uniqueDataSources
?.map((item) => this.utils.checkTranslation('name', item.organization))
?.map((item) => this.utils.checkTranslation('name', item.organization)).sort()
.join(', ');

return new Person(
Expand All @@ -172,7 +173,8 @@ export class PersonAdapter implements Adapter<Person> {
fieldsOfScience,
keywords,
collaboration,
uniqueDataSources
uniqueDataSources,
data.updated
);
}
}
8 changes: 0 additions & 8 deletions src/app/portal/services/filters/filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,16 +1080,8 @@ export class FilterService {
// If publications are searched without a search term then set sort as publicationYear
if (tab === 'publications') {
sortOrder.push({publicationYear: {order:'desc'}});
} else {
sortOrder.push('_score');
}
} else {
if (tab === 'publications') {
sortOrder.push('_score');
sortOrder.push({publicationYear: {order:'desc'}});
} else {
sortOrder.push('_score');
}
}

const queryPayload = searchTerm.length > 0 ? query : randomQuery;
Expand Down
78 changes: 70 additions & 8 deletions src/app/portal/services/sort.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,78 @@ export class SortService {
break;
}
case 'persons': {
this.sort = [
{
'personal.names.lastName.keyword': {
order: this.sortDirection ? 'desc' : 'asc',
unmapped_type: 'long',
},
},
];
switch (this.sortColumn) {
case 'name': {
this.sort = [
{
'personal.names.lastName.keyword': {
order: this.sortDirection ? 'desc' : 'asc',
mode: "min",
unmapped_type : "long",
},
},
];
break;
}
case 'organization': {
const organizationSortString = 'activity.affiliations.organizationName' +
this.localeC +
'.keyword';
this.sort = [
{
[organizationSortString]: {
order: this.sortDirection ? 'desc' : 'asc',
mode: "min",
nested: this.generateNested('activity.affiliations'),
unmapped_type : "long",
},
},
];
break;
}
case 'positionName': {
const organizationSortString = 'activity.affiliations.positionName' +
this.localeC +
'.keyword';
this.sort = [
{
[organizationSortString]: {
order: this.sortDirection ? 'desc' : 'asc',
mode: "min",
nested: this.generateNested('activity.affiliations'),
unmapped_type : "long",
},
},
];
break;
}
case 'keywords': {
this.sort = [
{
'personal.keywords.value.keyword': {
order: this.sortDirection ? 'desc' : 'asc',
mode: "min",
unmapped_type : "long",
},
},
];
break;
}
default: {
this.sort = [
{
'updated': {
order: 'desc',
unmapped_type : "long",
},
}
];
break;
}
}
break;
}

case 'fundings': {
this.yearField = 'fundingStartYear';
switch (this.sortColumn) {
Expand Down

0 comments on commit b77d72d

Please sign in to comment.