From b496cfd52c499947c95f1a2fd4c681b65586c306 Mon Sep 17 00:00:00 2001 From: Kazgatari <56477241+Kazgatari@users.noreply.github.com> Date: Wed, 17 Jun 2026 11:46:16 +0200 Subject: [PATCH] removed old code and truncated cards in person search to keep layout static --- service/sentence_transformer/index_topics.py | 82 ------------------- .../person-card/person-card.component.html | 36 ++++---- .../person-card/person-card.component.scss | 39 ++++++++- .../person-card/person-card.component.ts | 40 ++++++--- 4 files changed, 86 insertions(+), 111 deletions(-) diff --git a/service/sentence_transformer/index_topics.py b/service/sentence_transformer/index_topics.py index 35cea0cb..7b506427 100644 --- a/service/sentence_transformer/index_topics.py +++ b/service/sentence_transformer/index_topics.py @@ -35,15 +35,6 @@ headers = { "Content-Type": "application/json" } -def float_array_to_base64(vector): - """ - Convert a float vector into a Base64 string representing 32-bit big-endian float bytes. - Elasticsearch expects big-endian floats for binary/Base64 dense_vector encoding. - """ - arr = np.asarray(vector, dtype=np.float32) - big_endian_bytes = arr.astype('>f4').tobytes() - return base64.b64encode(big_endian_bytes).decode('utf-8') - def split_into_sentences(text): if not text: return [] @@ -52,77 +43,6 @@ def split_into_sentences(text): # Filter out empty or extremely short sentences return [s for s in sentences if len(s.strip()) > 3] -def check_and_update_mapping(): - print("Checking 'topicvectors' index...") - - with httpx.Client(timeout=30.0) as client: - exists_resp = client.head(f"{ELASTIC_URL}topicvectors", headers=headers) - if exists_resp.status_code == 404: - print("Index 'topicvectors' does not exist. Creating index with mapping...") - create_payload = { - "mappings": { - "properties": { - "id": {"type": "keyword"}, - "display_name": { - "type": "text", - "fields": { - "keyword": {"type": "keyword", "ignore_above": 256} - } - }, - "display_name_vector": { - "type": "dense_vector", - "dims": 768, - "index": True, - "similarity": "cosine", - "index_options": { - "type": "int8_hnsw", - "m": 16, - "ef_construction": 100 - } - }, - "description": {"type": "text"}, - "description_vectors": { - "type": "nested", - "properties": { - "vector": { - "type": "dense_vector", - "dims": 768, - "index": True, - "similarity": "cosine", - "index_options": { - "type": "int8_hnsw", - "m": 16, - "ef_construction": 100 - } - } - } - }, - "keywords": { - "type": "text", - "fields": { - "keyword": {"type": "keyword"} - } - }, - "cited_by_count": {"type": "long"}, - "works_count": {"type": "long"}, - "updated_date": {"type": "date"}, - "created_date": {"type": "date"} - } - } - } - resp = client.put( - f"{ELASTIC_URL}topicvectors", - json=create_payload, - headers=headers - ) - if resp.status_code == 200: - print("Successfully created 'topicvectors' index.") - else: - print(f"Failed to create index: {resp.status_code} - {resp.text}") - resp.raise_for_status() - else: - print("Index 'topicvectors' already exists.") - def fetch_all_topics(): print("Fetching topics from 'openalex-topics'...") topics = [] @@ -204,8 +124,6 @@ def bulk_index_topics(topics, display_name_vectors, nested_description_vectors): print(f"Indexed batch {i} to {i + len(batch_topics)}") def main(): - check_and_update_mapping() - topics = fetch_all_topics() if not topics: print("No topics found. Exiting.") 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 d8e39eae..43698f60 100644 --- a/webapp/src/app/modules/person-card/person-card.component.html +++ b/webapp/src/app/modules/person-card/person-card.component.html @@ -5,15 +5,7 @@ {{ getInitials(person.display_name) }}
-
- @if (person.relevance_rating) { - - {{ person.relevance_rating }} - - } +
@@ -60,9 +56,12 @@ " >apartment - {{ - inst.display_name ?? '' | truncate: 30 - }} + {{ inst.display_name ?? '' }} @if (inst.country_code && !loading) { {{ inst.country_code.toUpperCase() }} 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 02be7ac6..f3a53722 100644 --- a/webapp/src/app/modules/person-card/person-card.component.scss +++ b/webapp/src/app/modules/person-card/person-card.component.scss @@ -108,6 +108,11 @@ font-size: 16px; font-weight: 600; color: var(--sg-text); + min-height: 24px; + line-height: 24px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; } .institution { display: flex; @@ -133,6 +138,26 @@ display: inline-flex; align-items: center; transition: all 0.2s ease; + max-width: 100%; + box-sizing: border-box; + + .institution-name { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + min-width: 0; + flex: 1; + } + + .flag-img { + flex-shrink: 0; + } + + .country-code { + display: inline-block; + flex-shrink: 0; + white-space: nowrap; + } &:hover { background: var(--sg-primary); @@ -143,13 +168,15 @@ .flag-img { border: 1px solid; - vertical-align: -10px; + vertical-align: middle; } .person-id { margin: 2px 0 0; font-size: 10px; color: var(--sg-text-soft); + min-height: 15px; + line-height: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; @@ -159,6 +186,11 @@ margin: 4px 0 0; font-size: 10px; color: var(--sg-text-muted); + min-height: 15px; + line-height: 15px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .card-body { @@ -186,6 +218,11 @@ border-radius: 4px; cursor: pointer; transition: all 0.2s ease; + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + box-sizing: border-box; &:hover { background: var(--sg-primary-soft); 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 13e889bd..89f0440c 100644 --- a/webapp/src/app/modules/person-card/person-card.component.ts +++ b/webapp/src/app/modules/person-card/person-card.component.ts @@ -3,18 +3,11 @@ import { CommonModule } from '@angular/common'; import { RouterLink } from '@angular/router'; import { MatIconModule } from '@angular/material/icon'; import { CustomAuthor, DehydratedInstitution, WorkTopic } from '../../api'; -import { TruncatePipe } from '../../shared/pipes/truncate.pipe'; import { SkTextDirective } from '../../custom-directives/sk-text.directive'; @Component({ selector: 'app-person-card', standalone: true, - imports: [ - CommonModule, - RouterLink, - MatIconModule, - TruncatePipe, - SkTextDirective, - ], + imports: [CommonModule, RouterLink, MatIconModule, SkTextDirective], templateUrl: './person-card.component.html', styleUrl: './person-card.component.scss', }) @@ -62,8 +55,11 @@ export class PersonCardComponent { if (topic.field?.display_name) parts.push(topic.field.display_name); if (topic.subfield?.display_name) parts.push(topic.subfield.display_name); - if (parts.length === 0) return topic.display_name || ''; - return parts.join(' - '); + const path = parts.join(' - '); + if (topic.display_name) { + return path ? `${topic.display_name}\n(${path})` : topic.display_name; + } + return path; } getDistinguishingId(person: CustomAuthor): string { @@ -74,6 +70,30 @@ export class PersonCardComponent { return ''; } + getStatsString(): string { + const works = this.person.works_count; + const citations = this.person.cited_by_count; + const hasWorks = works !== undefined && works !== null; + const hasCitations = citations !== undefined && citations !== null; + + if (hasWorks && hasCitations) { + return `Publikationen: ${works} · Zitationen: ${citations}`; + } else if (hasWorks) { + return `Publikationen: ${works}`; + } else if (hasCitations) { + return `Zitationen: ${citations}`; + } + return ''; + } + + getHIndexString(): string { + const hIndex = this.person.summary_stats?.h_index; + if (hIndex !== undefined && hIndex !== null) { + return `h_index: ${hIndex}`; + } + return ''; + } + toggleBookmark(): void { this.bookmarkToggle.emit(this.person); }