From 6e3c5107f1bf551e17e1fdc9e0cc5c262ff8d4b0 Mon Sep 17 00:00:00 2001 From: louis-19041904 Date: Thu, 18 Jun 2026 23:09:32 +0200 Subject: [PATCH] show career stage on person cards --- service/src/main/inse/persons/logic.py | 11 +++++++ .../person-card/person-card.component.html | 12 +++++++ .../person-card/person-card.component.scss | 33 +++++++++++++++++++ .../person-card/person-card.component.ts | 22 ++++++++++++- .../src/app/resolvers/person-list.resolver.ts | 2 +- 5 files changed, 78 insertions(+), 2 deletions(-) diff --git a/service/src/main/inse/persons/logic.py b/service/src/main/inse/persons/logic.py index 609b8b88..63c4d128 100644 --- a/service/src/main/inse/persons/logic.py +++ b/service/src/main/inse/persons/logic.py @@ -680,11 +680,22 @@ def advanced_search_persons( hits = response_dict.get("hits", {}).get("hits", []) total_count = response_dict.get("hits", {}).get("total", {}).get("value", 0) + include_career_metrics = include is None or "career_metrics" in include results = [] for hit in hits: raw_data = util.get_persons_data(hit) custom_author = _enrich_author_data(raw_data) if custom_author: + if include_career_metrics: + start_time = time.time() + custom_author.career_metrics = get_career_metrics_for_author( + custom_author.id + ) + elapsed_time = time.time() - start_time + logger.info( + f"Career metrics calculation for author {custom_author.id} took " + f"{elapsed_time:.2f} seconds" + ) results.append(custom_author) return CustomAuthorsListResponse( diff --git a/webapp/src/app/modules/person-card/person-card.component.html b/webapp/src/app/modules/person-card/person-card.component.html index 43698f60..59e1fc6b 100644 --- a/webapp/src/app/modules/person-card/person-card.component.html +++ b/webapp/src/app/modules/person-card/person-card.component.html @@ -33,6 +33,18 @@

{{ getHIndexString() }}

+ @if (!loading && getCareerStage(); as careerStage) { +
+ Career Stage: + + {{ careerStage }} + +
+ } diff --git a/webapp/src/app/modules/person-card/person-card.component.scss b/webapp/src/app/modules/person-card/person-card.component.scss index f3a53722..8aebf59a 100644 --- a/webapp/src/app/modules/person-card/person-card.component.scss +++ b/webapp/src/app/modules/person-card/person-card.component.scss @@ -193,6 +193,39 @@ white-space: nowrap; } +.career-stage-line { + display: flex; + align-items: center; + gap: 6px; + margin-top: 6px; + color: var(--sg-text-muted); + font-size: 10px; + min-height: 18px; +} + +.career-stage-label { + flex-shrink: 0; +} + +.career-stage-chip { + display: inline-flex; + align-items: center; + min-width: 0; + max-width: 100%; + padding: 2px 8px; + border: 1px solid var(--sg-border); + border-radius: 999px; + background: var(--sg-surface-muted); + color: var(--sg-primary); + font-size: 10px; + font-weight: 600; + line-height: 1.2; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + cursor: help; +} + .card-body { padding: 16px; flex-grow: 1; diff --git a/webapp/src/app/modules/person-card/person-card.component.ts b/webapp/src/app/modules/person-card/person-card.component.ts index 89f0440c..c7815275 100644 --- a/webapp/src/app/modules/person-card/person-card.component.ts +++ b/webapp/src/app/modules/person-card/person-card.component.ts @@ -2,12 +2,19 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterLink } from '@angular/router'; import { MatIconModule } from '@angular/material/icon'; +import { MatTooltipModule } from '@angular/material/tooltip'; import { CustomAuthor, DehydratedInstitution, WorkTopic } from '../../api'; import { SkTextDirective } from '../../custom-directives/sk-text.directive'; @Component({ selector: 'app-person-card', standalone: true, - imports: [CommonModule, RouterLink, MatIconModule, SkTextDirective], + imports: [ + CommonModule, + RouterLink, + MatIconModule, + MatTooltipModule, + SkTextDirective, + ], templateUrl: './person-card.component.html', styleUrl: './person-card.component.scss', }) @@ -94,6 +101,19 @@ export class PersonCardComponent { return ''; } + getCareerStage(): string | null { + const stage = this.person.career_metrics?.career_stage; + + if (!stage || stage === 'unknown') { + return null; + } + + return stage; + } + + readonly careerStageTooltip = + 'Dies ist eine Einschätzung zur Karrierephase, die ausschließlich auf OpenAlex-Publikationsdaten basiert. Es ist kein offizieller akademischer Status.'; + toggleBookmark(): void { this.bookmarkToggle.emit(this.person); } diff --git a/webapp/src/app/resolvers/person-list.resolver.ts b/webapp/src/app/resolvers/person-list.resolver.ts index 8e4b824c..926dd58c 100644 --- a/webapp/src/app/resolvers/person-list.resolver.ts +++ b/webapp/src/app/resolvers/person-list.resolver.ts @@ -12,7 +12,7 @@ export const personListResolver: ResolveFn = ( return [val]; }; const defaultIncludes = - 'display_name,works_count,cited_by_count,summary_stats,topics,orcid,relevance_rating,last_known_institutions,affiliations'; + 'display_name,works_count,cited_by_count,summary_stats,topics,orcid,relevance_rating,last_known_institutions,affiliations,career_metrics'; const params = route.queryParamMap; const query = params.get('query') || undefined;