diff --git a/service/src/main/inse/ranking/logic.py b/service/src/main/inse/ranking/logic.py index e8aacfd5..8313217f 100644 --- a/service/src/main/inse/ranking/logic.py +++ b/service/src/main/inse/ranking/logic.py @@ -24,6 +24,7 @@ from .model import ( FilterType, KeywordOperator, PublicationType, + PublicationTypeCount, RankedAuthor, RankingWeights, SubfieldShare, @@ -788,6 +789,84 @@ def _build_query( } +def _build_publication_type_counts_query( + keywords: list[str], + operator: KeywordOperator, + author_ids: list[str], + timespan: Timespan | None, + config: MatchConfig = _KEYWORD_MATCH, +) -> dict: + """Builds the query that counts matching works per publication type. + + Mirrors _build_query's work filters but leaves out the publication_types + filter itself, since it aggregates over all types instead of one score. + """ + work_filters = [ + _build_keyword_query(keywords, operator, config), + _author_filter(author_ids), + ] + if timespan is not None: + work_filters.append(_timespan_filter(timespan)) + + return { + "size": 0, + "query": { + "bool": { + "filter": work_filters, + }, + }, + "aggs": { + "by_type": { + "terms": { + "field": "type", + "size": len(PublicationType), + }, + }, + }, + } + + +async def publication_type_counts_for_keywords( + keywords: list[str], + operator: KeywordOperator, + institution_id: str, + career_stages: list[CareerStage], + timespan: Timespan | None, + filter_type: FilterType = FilterType.KEYWORD, +) -> list[PublicationTypeCount]: + """Counts the university's matching works per publication type, largest first.""" + author_ids = await _get_author_ids_from_institution(institution_id) + + if not author_ids: + return [] + + if career_stages: + author_ids = await _filter_author_ids_by_career_stage(author_ids, career_stages) + + query_body = _build_publication_type_counts_query( + keywords, operator, author_ids, timespan, _match_config(filter_type), + ) + + response: dict[str, Any] = await elasticsearch.search( + index=config.settings.openalex_works_search_index, + body=query_body, + cluster=ESCluster.NES, + ) + + type_buckets = response.get("aggregations", {}).get("by_type", {}).get("buckets", []) + + counts = [] + for bucket in type_buckets: + try: + publication_type = PublicationType(bucket["key"]) + except ValueError: + continue + counts.append(PublicationTypeCount(type=publication_type, count=bucket["doc_count"])) + + counts.sort(key=lambda c: c.count, reverse=True) + return counts + + def _display_name_from_bucket(author_bucket: dict) -> str: """Reads the authors display name out of the name sub-aggregation.""" name_buckets = author_bucket.get("author_name", {}).get("buckets", []) diff --git a/service/src/main/inse/ranking/model.py b/service/src/main/inse/ranking/model.py index 75522114..f4de7b12 100644 --- a/service/src/main/inse/ranking/model.py +++ b/service/src/main/inse/ranking/model.py @@ -195,6 +195,42 @@ class AuthorMetricsRequest(BaseModel): ) +class PublicationTypeCountsRequest(BaseModel): + keywords: list[str] = Field( + min_length=1, + description="One or more keywords to match works against.", + ) + operator: KeywordOperator = Field( + default=KeywordOperator.AND, + description="How to combine the keywords: 'and' or 'or'. Defaults to 'and'.", + ) + filter_type: FilterType = Field( + default=FilterType.KEYWORD, + description="What the 'keywords' values match against: 'keyword' (OpenAlex " + "keyword display names) or 'topic' (OpenAlex topic display names). Defaults to 'keyword'.", + ) + career_stages: list[CareerStage] = Field( + default_factory=list, + description="Optional filter: only count works of authors in one of these career stages. Empty = no filter.", + ) + timespan: Timespan | None = Field( + default=None, + description="Optional filter: only count works whose publication_year is within [from, to].", + ) + + @field_validator("operator", "filter_type", mode="before") + @classmethod + def operator_case_insensitive(cls, value): + if isinstance(value, str): + return value.lower() + return value + + +class PublicationTypeCount(BaseModel): + type: PublicationType = Field(description="The OpenAlex work type.") + count: int = Field(description="Number of matching works of this type.") + + class AuthorTopicStats(BaseModel): """Section 1: combined stats over an author's works that match the topic filter.""" diff --git a/service/src/main/inse/ranking/router.py b/service/src/main/inse/ranking/router.py index cb645d5a..e0f0dd9b 100644 --- a/service/src/main/inse/ranking/router.py +++ b/service/src/main/inse/ranking/router.py @@ -14,6 +14,8 @@ from .model import ( AuthorTopicProfile, AuthorTopicStats, KeywordToAuthorRequest, + PublicationTypeCount, + PublicationTypeCountsRequest, RankedAuthor, SelectedAuthorsRequest, ) @@ -68,6 +70,40 @@ async def rank_author( filter_type=request.filter_type, ) +# Publication-type facet counts for the "Art der Work" filter +@router.post("/publication-type-counts", response_model=list[PublicationTypeCount]) +async def publication_type_counts( + request: PublicationTypeCountsRequest, + access_token_metadata: Annotated[ + AccessTokenMetadata, CurrentUserAccessTokenPayloadDep + ], +): + institution_id = access_token_metadata.effective_institution_id + if not institution_id: + raise HTTPException( + status_code=status.HTTP_403_FORBIDDEN, + detail="No OpenAlex institution is assigned to the current organization.", + ) + + logger.info( + "publication-type-counts keywords=%s operator=%s filter_type=%s institution_id=%s " + "career_stages=%s timespan=%s", + request.keywords, + request.operator, + request.filter_type, + institution_id, + request.career_stages, + request.timespan, + ) + return await logic.publication_type_counts_for_keywords( + keywords=request.keywords, + operator=request.operator, + institution_id=institution_id, + career_stages=request.career_stages, + timespan=request.timespan, + filter_type=request.filter_type, + ) + # Compare authors table 1 (topic stats) @router.post("/topic-stats", response_model=list[AuthorTopicStats]) async def topic_stats(request: SelectedAuthorsRequest): diff --git a/webapp/src/app/api/api/ranking.service.ts b/webapp/src/app/api/api/ranking.service.ts index a74696b6..3d3bbea6 100644 --- a/webapp/src/app/api/api/ranking.service.ts +++ b/webapp/src/app/api/api/ranking.service.ts @@ -39,6 +39,10 @@ import { HTTPValidationError } from '../model/hTTPValidationError'; // @ts-ignore import { KeywordToAuthorRequest } from '../model/keywordToAuthorRequest'; // @ts-ignore +import { PublicationTypeCount } from '../model/publicationTypeCount'; +// @ts-ignore +import { PublicationTypeCountsRequest } from '../model/publicationTypeCountsRequest'; +// @ts-ignore import { RankedAuthor } from '../model/rankedAuthor'; // @ts-ignore import { SelectedAuthorsRequest } from '../model/selectedAuthorsRequest'; @@ -191,6 +195,136 @@ export class RankingService extends BaseService { ); } + /** + * Publication Type Counts + * @endpoint post /api/rank/publication-type-counts + * @param publicationTypeCountsRequest + * @param secureFgpAcc + * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. + * @param reportProgress flag to report request and response progress. + */ + public publicationTypeCountsApiRankPublicationTypeCountsPost( + publicationTypeCountsRequest: PublicationTypeCountsRequest, + secureFgpAcc?: string, + observe?: 'body', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>; + public publicationTypeCountsApiRankPublicationTypeCountsPost( + publicationTypeCountsRequest: PublicationTypeCountsRequest, + secureFgpAcc?: string, + observe?: 'response', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>>; + public publicationTypeCountsApiRankPublicationTypeCountsPost( + publicationTypeCountsRequest: PublicationTypeCountsRequest, + secureFgpAcc?: string, + observe?: 'events', + reportProgress?: boolean, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable>>; + public publicationTypeCountsApiRankPublicationTypeCountsPost( + publicationTypeCountsRequest: PublicationTypeCountsRequest, + secureFgpAcc?: string, + observe: any = 'body', + reportProgress: boolean = false, + options?: { + httpHeaderAccept?: 'application/json'; + context?: HttpContext; + transferCache?: boolean; + }, + ): Observable { + if ( + publicationTypeCountsRequest === null || + publicationTypeCountsRequest === undefined + ) { + throw new Error( + 'Required parameter publicationTypeCountsRequest was null or undefined when calling publicationTypeCountsApiRankPublicationTypeCountsPost.', + ); + } + + let localVarHeaders = this.defaultHeaders; + + // authentication (HTTPBearer) required + localVarHeaders = this.configuration.addCredentialToHeaders( + 'HTTPBearer', + 'Authorization', + localVarHeaders, + 'Bearer ', + ); + + const localVarHttpHeaderAcceptSelected: string | undefined = + options?.httpHeaderAccept ?? + this.configuration.selectHeaderAccept(['application/json']); + if (localVarHttpHeaderAcceptSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Accept', + localVarHttpHeaderAcceptSelected, + ); + } + + const localVarHttpContext: HttpContext = + options?.context ?? new HttpContext(); + + const localVarTransferCache: boolean = options?.transferCache ?? true; + + // to determine the Content-Type header + const consumes: string[] = ['application/json']; + const httpContentTypeSelected: string | undefined = + this.configuration.selectHeaderContentType(consumes); + if (httpContentTypeSelected !== undefined) { + localVarHeaders = localVarHeaders.set( + 'Content-Type', + httpContentTypeSelected, + ); + } + + let responseType_: 'text' | 'json' | 'blob' = 'json'; + if (localVarHttpHeaderAcceptSelected) { + if (localVarHttpHeaderAcceptSelected.startsWith('text')) { + responseType_ = 'text'; + } else if ( + this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected) + ) { + responseType_ = 'json'; + } else { + responseType_ = 'blob'; + } + } + + let localVarPath = `/api/rank/publication-type-counts`; + const { basePath, withCredentials } = this.configuration; + return this.httpClient.request>( + 'post', + `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + body: publicationTypeCountsRequest, + responseType: responseType_, + ...(withCredentials ? { withCredentials } : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined + ? { transferCache: localVarTransferCache } + : {}), + reportProgress: reportProgress, + }, + ); + } + /** * Rank Author * @endpoint post /api/rank/rank-author diff --git a/webapp/src/app/api/model/models.ts b/webapp/src/app/api/model/models.ts index d6da3737..0a1a7530 100644 --- a/webapp/src/app/api/model/models.ts +++ b/webapp/src/app/api/model/models.ts @@ -202,6 +202,8 @@ export * from './projectsSortBy'; export * from './publicationDetailByFunder'; export * from './publicationIdsByAuthorPosition'; export * from './publicationType'; +export * from './publicationTypeCount'; +export * from './publicationTypeCountsRequest'; export * from './publicationsByAuthorResponse'; export * from './rankedAuthor'; export * from './rankingResponse'; diff --git a/webapp/src/app/api/model/publicationTypeCount.ts b/webapp/src/app/api/model/publicationTypeCount.ts new file mode 100644 index 00000000..693dab21 --- /dev/null +++ b/webapp/src/app/api/model/publicationTypeCount.ts @@ -0,0 +1,22 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { PublicationType } from './publicationType'; + +export interface PublicationTypeCount { + /** + * The OpenAlex work type. + */ + type: PublicationType; + /** + * Number of matching works of this type. + */ + count: number; +} +export namespace PublicationTypeCount {} diff --git a/webapp/src/app/api/model/publicationTypeCountsRequest.ts b/webapp/src/app/api/model/publicationTypeCountsRequest.ts new file mode 100644 index 00000000..fe24986b --- /dev/null +++ b/webapp/src/app/api/model/publicationTypeCountsRequest.ts @@ -0,0 +1,34 @@ +/** + * Innovation Search Engine API + * + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +import { Timespan } from './timespan'; +import { FilterType } from './filterType'; +import { CareerStage } from './careerStage'; +import { KeywordOperator } from './keywordOperator'; + +export interface PublicationTypeCountsRequest { + /** + * One or more keywords to match works against. + */ + keywords: Array; + /** + * How to combine the keywords: \'and\' or \'or\'. Defaults to \'and\'. + */ + operator?: KeywordOperator; + /** + * What the \'keywords\' values match against: \'keyword\' (OpenAlex keyword display names) or \'topic\' (OpenAlex topic display names). Defaults to \'keyword\'. + */ + filter_type?: FilterType; + /** + * Optional filter: only count works of authors in one of these career stages. Empty = no filter. + */ + career_stages?: Array; + timespan?: Timespan | null; +} +export namespace PublicationTypeCountsRequest {} diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.html b/webapp/src/app/modules/compare-authors/compare-authors.component.html index 1ddf076c..acc2e968 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.html +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.html @@ -32,7 +32,19 @@ Betrachtete Personen:
@for (author of summary(); track author.authorId) { - {{ author.name }} + + + {{ author.name }} + open_in_new + + }
@@ -159,7 +171,19 @@ Kennzahl @for (author of summary(); track author.authorId) { - {{ author.name }} + + + {{ author.name }} + open_in_new + + } @@ -168,7 +192,16 @@ @for (row of rows; track row.label) { - {{ row.label }} + + {{ row.label }} + @if (row.nameMatched) { + + } + {{ row.hint }} @if (row.kind === 'group') { @@ -222,4 +255,12 @@ + @if (hasNameMatchedRow(rows)) { +

+ star + Diese Kennzahlen basieren auf einem automatischen Namensabgleich mit + externen Quellen, wodurch es in Einzelfällen zu Fehlzuordnungen kommen + kann. +

+ } diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.scss b/webapp/src/app/modules/compare-authors/compare-authors.component.scss index f34f907b..150ec838 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.scss +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.scss @@ -60,6 +60,28 @@ app-chip mat-icon { vertical-align: text-bottom; } +.chip-link { + display: inline-flex; + align-items: center; + gap: 4px; + margin: -4px -12px; + padding: 4px 12px; + color: inherit; + text-decoration: none; + cursor: pointer; + + mat-icon { + font-size: 14px; + width: 14px; + height: 14px; + opacity: 0.7; + } + + &:hover mat-icon { + opacity: 1; + } +} + /* ---- cards ---- */ .card { background: var(--sg-card-bg); @@ -122,7 +144,10 @@ app-chip mat-icon { } .metric-label { - display: block; + display: flex; + align-items: center; + justify-content: center; + gap: 4px; font-weight: 600; color: var(--sg-text); } @@ -135,6 +160,31 @@ app-chip mat-icon { color: var(--sg-text-soft); } +.icon-small { + font-size: 14px; + width: 14px; + height: 14px; + vertical-align: text-bottom; +} + +.name-match-star { + color: var(--sg-warning, #b8860b); +} + +.name-match-note { + display: flex; + align-items: center; + gap: 6px; + margin: 10px 0 0; + font-size: 12px; + color: var(--sg-text-muted); + + mat-icon { + flex: 0 0 auto; + color: var(--sg-warning, #b8860b); + } +} + .value-cell { text-align: center; font-variant-numeric: tabular-nums; diff --git a/webapp/src/app/modules/compare-authors/compare-authors.component.ts b/webapp/src/app/modules/compare-authors/compare-authors.component.ts index d1a38945..bcd14ca5 100644 --- a/webapp/src/app/modules/compare-authors/compare-authors.component.ts +++ b/webapp/src/app/modules/compare-authors/compare-authors.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit, computed, inject, signal } from '@angular/core'; import { DecimalPipe, NgTemplateOutlet } from '@angular/common'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, RouterLink } from '@angular/router'; import { MatIconModule } from '@angular/material/icon'; import { EChartsOption } from 'echarts'; import { NgxEchartsDirective } from 'ngx-echarts'; @@ -98,6 +98,7 @@ interface MetricRow { cells: MetricCell[]; segments: GroupSegment[]; groupCells: GroupCell[]; + nameMatched: boolean; } interface RowDef { @@ -105,6 +106,7 @@ interface RowDef { hint: string; select: (a: AuthorSummary) => number | null; decimals?: boolean; + nameMatched?: boolean; } interface SegmentDef { @@ -121,6 +123,7 @@ interface SegmentDef { imports: [ DecimalPipe, NgTemplateOutlet, + RouterLink, MatIconModule, NgxEchartsDirective, AuthorResearchProfileComponent, @@ -385,15 +388,18 @@ export class CompareAuthorsComponent implements OnInit { label: 'Unternehmensgründungen', hint: 'Handelsregister-Verbindungen über den Namen', select: (a) => a.companies, + nameMatched: true, }, { label: 'News-Artikel', hint: 'Nachrichtenartikel, die die Person namentlich nennen', select: (a) => a.news, + nameMatched: true, }, { label: 'Patente', hint: 'Der Person zugeordnete Patente', + nameMatched: true, select: (a) => a.patents, }, ]), @@ -469,6 +475,11 @@ export class CompareAuthorsComponent implements OnInit { ); } + authorProfileId(authorId: string): string { + const parts = authorId.split('/'); + return parts[parts.length - 1]; + } + // colours the author names on the chart axes like the legend chips private authorAxisLabel(profiles: AuthorTopicProfile[]) { const rich: Record = {}; @@ -707,6 +718,7 @@ export class CompareAuthorsComponent implements OnInit { })), segments: [], groupCells: [], + nameMatched: def.nameMatched ?? false, }; }); } @@ -731,9 +743,14 @@ export class CompareAuthorsComponent implements OnInit { groupCells: this.summary().map((a) => ({ values: segs.map((s) => s.select(a)), })), + nameMatched: false, }; } + hasNameMatchedRow(rows: MetricRow[]): boolean { + return rows.some((row) => row.nameMatched); + } + ngOnInit(): void { // everything is read from the URL so a shared link lands on the same view const rawAuthors = this.route.snapshot.queryParamMap.get('authors') ?? ''; diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html index ae13af47..e1ff133b 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.html @@ -104,8 +104,10 @@ } - @for (pt of filteredPubTypes(); track pt) { - {{ pt }} + @for (pt of filteredPubTypes(); track pt.type) { + {{ pt.type }} ({{ pt.count }}) } diff --git a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts index fb4a1bf1..43a0103b 100644 --- a/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/persons-results/persons-results.component.ts @@ -25,6 +25,8 @@ import { YearRangeSliderComponent } from '../../../../shared/ui/year-range-slide import { CareerStage, KeywordToAuthorRequest, + PublicationTypeCount, + PublicationTypeCountsRequest, RankedAuthor, RankingService, } from '../../../../api'; @@ -116,6 +118,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { icon: 'business', description: 'Gewichtet die Anzahl der Unternehmensgründungen (Handelsregister-Verbindungen).', + nameMatched: true, defaultValue: 0.5, queryParamName: 'wCompanies', }, @@ -125,6 +128,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { icon: 'visibility', description: 'Gewichtet die öffentliche Sichtbarkeit über Nennungen in Nachrichtenartikeln.', + nameMatched: true, defaultValue: 0.5, queryParamName: 'wNews', }, @@ -133,6 +137,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { label: 'Patente', icon: 'workspace_premium', description: 'Gewichtet Innovations- und Transferleistung über Patente.', + nameMatched: true, defaultValue: 0.5, queryParamName: 'wPatents', }, @@ -174,33 +179,8 @@ export class KeywordsToPersonsResultsComponent implements OnInit { ]; readonly companyStatus = signal<'all' | 'active' | 'deleted'>('all'); - // publication types - readonly ALL_PUBLICATION_TYPES = [ - 'article', - 'other', - 'dataset', - 'book-chapter', - 'book', - 'dissertation', - 'preprint', - 'paratext', - 'libguides', - 'review', - 'letter', - 'reference-entry', - 'editorial', - 'peer-review', - 'report', - 'standard', - 'erratum', - 'retraction', - 'supplementary-materials', - 'book-section', - 'database', - 'software', - 'report-component', - 'grant', - ]; + // publication types: counted from the index (count-by), largest first + readonly publicationTypeCounts = signal([]); readonly pubTypeSearchTerm = signal(''); @@ -213,10 +193,9 @@ export class KeywordsToPersonsResultsComponent implements OnInit { readonly filteredPubTypes = computed(() => { const term = this.pubTypeSearchTerm().toLowerCase(); - if (!term) return this.ALL_PUBLICATION_TYPES; - return this.ALL_PUBLICATION_TYPES.filter((pt) => - pt.toLowerCase().includes(term), - ); + const counts = this.publicationTypeCounts(); + if (!term) return counts; + return counts.filter((pt) => pt.type.toLowerCase().includes(term)); }); onPubTypesChange(selected: string[]) { @@ -253,6 +232,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { replaceUrl: true, }); this.loadAuthors(); + this.loadPublicationTypeCounts(); } readonly CAREER_STAGE_OPTIONS = [ @@ -314,6 +294,8 @@ export class KeywordsToPersonsResultsComponent implements OnInit { if (operator === 'and' || operator === 'or') { this.keywordOperator.set(operator); } + + this.loadPublicationTypeCounts(); } // reads a year query param, clamped to the valid range; falls back on invalid input @@ -400,6 +382,7 @@ export class KeywordsToPersonsResultsComponent implements OnInit { } this.writeTimespanToUrl(); this.loadAuthors(); + this.loadPublicationTypeCounts(); } // the backend returns the full OpenAlex url; the profile route needs only the id @@ -494,4 +477,30 @@ export class KeywordsToPersonsResultsComponent implements OnInit { }, }); } + + // counts, by publication type, of the works matching the current keyword/ + // career-stage/timespan filters — drives the "Art der Work" filter options + private loadPublicationTypeCounts(): void { + const request: PublicationTypeCountsRequest = { + keywords: this.state.topicsList(), + operator: this.keywordOperator(), + filter_type: 'topic', + career_stages: + this.careerStages().length > 0 ? this.careerStages() : undefined, + timespan: { + from: this.timespanFrom(), + to: this.timespanTo(), + }, + }; + + this.rankingService + .publicationTypeCountsApiRankPublicationTypeCountsPost(request) + .subscribe({ + next: (counts) => this.publicationTypeCounts.set(counts), + error: (error) => { + console.error(error); + this.publicationTypeCounts.set([]); + }, + }); + } } diff --git a/webapp/src/app/modules/keywords-search/search-results/search-results.component.html b/webapp/src/app/modules/keywords-search/search-results/search-results.component.html index fcc5a94d..d242e9cd 100644 --- a/webapp/src/app/modules/keywords-search/search-results/search-results.component.html +++ b/webapp/src/app/modules/keywords-search/search-results/search-results.component.html @@ -22,9 +22,14 @@ + [checked]="state.fuzzySearch()" + [disabled]="isPersonsTab()"> Fuzzy Search @@ -72,8 +77,8 @@ [active]="rla.isActive" [queryParams]="{ keywords: state.payload()?.keywords?.join(','), - fuzzy: state.payload()?.options?.fuzzy, - topics: state.payload()?.options?.fuzzy ? state.topicIds() : null, + fuzzy: tabFuzzyValue(route), + topics: tabFuzzyValue(route) ? state.topicIds() : null, topicId: null, }" queryParamsHandling="replace"> diff --git a/webapp/src/app/modules/keywords-search/search-results/search-results.component.ts b/webapp/src/app/modules/keywords-search/search-results/search-results.component.ts index 76897874..d11c1216 100644 --- a/webapp/src/app/modules/keywords-search/search-results/search-results.component.ts +++ b/webapp/src/app/modules/keywords-search/search-results/search-results.component.ts @@ -63,6 +63,8 @@ export class KeywordsSearchResultsComponent { { path: 'trends', label: 'Visualisierung', icon: 'bar_chart' }, ]; + private readonly lastUserFuzzy = signal(false); + readonly selectedKeywordCount = computed(() => this.state.keywords().length); readonly allKeywordEntries = computed(() => { const seen = new Set(); @@ -85,7 +87,12 @@ export class KeywordsSearchResultsComponent { // previous search never gets silently applied to a new one. this.route.queryParamMap.pipe(takeUntilDestroyed()).subscribe((params) => { const keywords = this.parseKeywordList(params.get('keywords')); - const fuzzySearch = params.get('fuzzy') === 'true'; + const onPersonsTab = this.isPersonsTab(); + const fuzzySearch = onPersonsTab || params.get('fuzzy') === 'true'; + + if (!onPersonsTab) { + this.lastUserFuzzy.set(params.get('fuzzy') === 'true'); + } const cached = this.readHandoffCache(); const cacheMatches = @@ -100,8 +107,22 @@ export class KeywordsSearchResultsComponent { ? cached!.patentKeywordEntries : undefined, }); + + if (onPersonsTab && params.get('fuzzy') !== 'true') { + this.updateQueryParams(true); + } }); } + + // the Fuzzy Search toggle is locked on while the Personen tab is active + isPersonsTab(): boolean { + return this.route.snapshot.firstChild?.routeConfig?.path === 'persons'; + } + + tabFuzzyValue(route: { path: string }): boolean { + if (route.path === 'persons') return true; + return this.lastUserFuzzy(); + } goBackToSearch(): void { void this.router.navigate(['/keywords'], { queryParamsHandling: 'merge', diff --git a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.html b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.html index 0823bf1a..8e4a3d52 100644 --- a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.html +++ b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.html @@ -25,6 +25,11 @@ {{ option.icon }} } {{ option.label }} + @if (option.nameMatched) { + + }
@@ -51,6 +56,16 @@ }
+ + @if (hasNameMatchedOption) { +

+ star + Diese Kennzahlen basieren auf einem automatischen Namensabgleich mit + externen Quellen, wodurch es in Einzelfällen zu Fehlzuordnungen kommen + kann. +

+ } + @if (!weightsState().valid) {
diff --git a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss index 6b0c7fcd..39750a89 100644 --- a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss +++ b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.scss @@ -77,6 +77,7 @@ $touch-target: 44px; width: 14px; height: 14px; color: var(--sg-text-muted); + flex-shrink: 0; } span { @@ -84,6 +85,8 @@ $touch-target: 44px; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; + flex: 1; + min-width: 0; } } @@ -108,6 +111,28 @@ $touch-target: 44px; padding: 0 6px; } +::ng-deep .weight-label .icon-small.name-match-star { + color: var(--sg-warning, #b8860b); +} + +/* ============================================================ + NAME MATCH NOTE + ============================================================ */ +.name-match-note { + display: flex; + align-items: center; + gap: 0.3rem; + margin: 0.3rem 0 0; + padding: 0.2rem 0.3rem; + font-size: 0.7rem; + color: var(--sg-text-muted); + + mat-icon { + flex: 0 0 auto; + color: var(--sg-warning, #b8860b); + } +} + /* ============================================================ WARNING ============================================================ */ diff --git a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.ts b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.ts index 436499ff..8f43607c 100644 --- a/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.ts +++ b/webapp/src/app/shared/ui/weights-sliders/weights-sliders.component.ts @@ -28,6 +28,12 @@ export interface WeightSliderOption { icon?: string; description?: string; + /** + * Marks this metric with a star, indicating it relies on name matching + * (see weight-name-match-note in the template). + */ + nameMatched?: boolean; + /** * Optional default raw weight. * Must be between 0 and 1. @@ -212,6 +218,10 @@ export class WeightsSlidersComponent implements OnInit, OnChanges { } } + get hasNameMatchedOption(): boolean { + return this.options.some((option) => option.nameMatched); + } + weightControl(key: string): FormControl { const control = this.form.controls[key];