extract latest institution from affiliations if last_known_institutions is null #155
@@ -36,11 +36,25 @@ export class PersonCardComponent {
|
||||
}
|
||||
|
||||
institution(person: CustomAuthor): DehydratedInstitution | undefined {
|
||||
return (
|
||||
person.last_known_institutions?.[0] ||
|
||||
person.affiliations?.[person.affiliations.length - 1]?.institution ||
|
||||
undefined
|
||||
);
|
||||
if (person.last_known_institutions?.[0]) {
|
||||
return person.last_known_institutions[0];
|
||||
}
|
||||
|
||||
const affiliations = person.affiliations ?? [];
|
||||
let newestInstitution: DehydratedInstitution | undefined =
|
||||
affiliations[0]?.institution ?? undefined;
|
||||
let newestYear = -1;
|
||||
|
||||
for (const affiliation of affiliations) {
|
||||
for (const jahr of affiliation.years ?? []) {
|
||||
if (jahr > newestYear) {
|
||||
newestYear = jahr;
|
||||
newestInstitution = affiliation.institution ?? undefined;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return newestInstitution;
|
||||
}
|
||||
|
||||
topics(person: CustomAuthor): WorkTopic[] {
|
||||
|
||||
@@ -119,15 +119,20 @@ export class PersonComponent {
|
||||
() => this.person()?.affiliations?.[0] ?? null,
|
||||
);
|
||||
readonly lastAffiliation = computed(() => {
|
||||
let lastAffiliation: number | undefined = 0;
|
||||
if (this.person()?.affiliations?.length != undefined) {
|
||||
lastAffiliation = this.person()?.affiliations?.length;
|
||||
const affiliations = this.person()?.affiliations ?? [];
|
||||
let newestAffiliation = affiliations[0] ?? null;
|
||||
let newestYear = -1;
|
||||
|
||||
for (const affiliation of affiliations) {
|
||||
for (const jahr of affiliation.years ?? []) {
|
||||
if (jahr > newestYear) {
|
||||
newestYear = jahr;
|
||||
newestAffiliation = affiliation;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
(lastAffiliation
|
||||
? this.person()?.affiliations?.[lastAffiliation - 1]
|
||||
: this.person()?.affiliations?.[0]) ?? null
|
||||
);
|
||||
|
||||
return newestAffiliation;
|
||||
});
|
||||
readonly institution = computed(
|
||||
() =>
|
||||
|
||||
Reference in New Issue
Block a user