feat(backend/search): enhance sorting logic in person list by adding works count as a secondary criterion
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/pr-dev Build started...

This commit is contained in:
Steven Tischer
2026-06-02 07:24:07 +02:00
parent 1409d801bf
commit 2eb97bc4f7
@@ -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;