feat(backend/search): enhance sorting logic in person list by adding works count as a secondary criterion
This commit is contained in:
@@ -72,12 +72,20 @@ export class PersonListComponent {
|
||||
|
||||
return {
|
||||
...response,
|
||||
results: [...response.results].sort(
|
||||
(a, b) => this.getSortRank(a) - this.getSortRank(b)
|
||||
),
|
||||
results: [...response.results].sort((personA, personB) => {
|
||||
const rankDiff = this.getSortRank(personA) - this.getSortRank(personB);
|
||||
if (rankDiff !== 0) {
|
||||
return rankDiff;
|
||||
}
|
||||
return this.getWorksCount(personB) - this.getWorksCount(personA);
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
getWorksCount(person: Author): number {
|
||||
return person.works_count ?? 0;
|
||||
}
|
||||
|
||||
getSortRank(person: Author): number {
|
||||
if (this.hasInstitution(person) && this.hasOrcid(person)) return 0;
|
||||
if (this.hasInstitution(person)) return 1;
|
||||
|
||||
Reference in New Issue
Block a user