Merge branch 'ts-82-author-overview-and-description' of https://project.nes.uni-due.de/gitea/lbs/smartguide into ts-82-author-overview-and-description

This commit is contained in:
2026-05-31 11:18:35 +02:00
4 changed files with 87 additions and 2 deletions
+8
View File
@@ -366,6 +366,14 @@ def search_persons_by_name(author_name: str, limit: Optional[int] = 10) -> model
}
}
},
{
"match_phrase_prefix": {
"display_name": {
"query": author_name,
"boost": 3
}
}
},
{
"match": {
"display_name": {
@@ -1,3 +1,7 @@
@if (!isPersonsLoading && state.persons().length > 0) {
<p class="result-count">{{ state.persons().length }} Ergebnisse</p>
}
<mat-grid-list cols="1" rowHeight="220px" gutterSize="16px">
@if (!isPersonsLoading){
@for (person of state.persons(); track person.id) {
@@ -14,6 +18,7 @@
<div class="info">
<h3 class="name">{{ person.name }}</h3>
<p class="person-id">{{ getDistinguishingId(person) }}</p>
@if (person.affiliations!=undefined){
<p class="affiliation">
{{ person.affiliations[0]?.institution }}
@@ -1,3 +1,9 @@
.result-count {
margin: 0 0 12px;
font-size: 14px;
color: #666;
}
.person-card {
width: 100%;
height: 100%;
@@ -35,6 +41,12 @@
margin: 0;
}
.person-id {
font-size: 11px;
color: #aaa;
margin: 0;
}
.affiliation {
color: #666;
margin: 0;
@@ -43,7 +43,7 @@ export class PersonListComponent implements OnInit{
this.personsService.searchPersonsByName(author_name).subscribe({
next: (result) => {
this.state.persons.set(result.persons ?? []);
this.state.persons.set(this.sortByRanking(result.persons ?? []));
this.state.hasSearched.set(true);
this.isPersonsLoading = false
},
@@ -71,5 +71,65 @@ export class PersonListComponent implements OnInit{
console.log(id)
this.router.navigate(['/persons',id]);
}
sortByRanking(persons: Person[]): Person[] {
const personsByRank = new Map<number, Person[]>();
for (const person of persons) {
const rank = this.getSortRank(person);
if (!personsByRank.has(rank)) {
personsByRank.set(rank, []);
}
personsByRank.get(rank)!.push(person);
}
const sortedRanks = Array.from(personsByRank.keys()).sort((a, b) => a - b);
const sortedPersons: Person[] = [];
for (const rank of sortedRanks) {
sortedPersons.push(...personsByRank.get(rank)!);
}
return sortedPersons;
}
getSortRank(person: Person): number {
if (this.hasInstitution(person) && this.hasOrcid(person)) {
return 0;
}
if (this.hasInstitution(person)) {
return 1;
}
if (this.hasOrcid(person)) {
return 2;
}
return 3;
}
hasInstitution(person: Person): boolean {
if (!person.affiliations) {
return false;
}
for (const affiliation of person.affiliations) {
if (affiliation.institution) {
return true;
}
}
return false;
}
hasOrcid(person: Person): boolean {
const ids = person.ids as { orcid?: string } | null | undefined;
return !!ids?.orcid;
}
// if a person has an ORCID, use it as the distinguishing ID, otherwise use the regular ID
getDistinguishingId(person: Person): string {
const ids = person.ids as { orcid?: string } | null | undefined;
const orcid = ids?.orcid;
if (orcid) {
return 'ORCID: ' + orcid.replace('https://orcid.org/', '');
}
return 'OpenAlexID: ' + person.id;
}
}