show career stage on person cards
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -33,6 +33,18 @@
|
||||
<p [skText]="loading" class="stats">
|
||||
{{ getHIndexString() }}
|
||||
</p>
|
||||
@if (!loading && getCareerStage(); as careerStage) {
|
||||
<div [skText]="loading" class="career-stage-line">
|
||||
<span class="career-stage-label">Career Stage:</span>
|
||||
<span
|
||||
class="career-stage-chip"
|
||||
[matTooltip]="careerStageTooltip"
|
||||
matTooltipPosition="above"
|
||||
[matTooltipShowDelay]="250">
|
||||
{{ careerStage }}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</a>
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ export const personListResolver: ResolveFn<CustomAuthorsListResponse> = (
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user