Compare commits
56
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d48435b948 | ||
|
|
c054cf99fe | ||
|
|
98a742f024 | ||
|
|
1fc509ea13 | ||
|
|
90a1b930a3 | ||
|
|
9011d58355 | ||
|
|
f2c0f203f6 | ||
|
|
3f5746dd7d | ||
|
|
adce95ead4 | ||
|
|
84d7ca0122 | ||
|
|
053af573fc | ||
|
|
06f34bec45 | ||
|
|
c1641fdb38 | ||
|
|
9115af350e | ||
|
|
77cf3612d9 | ||
|
|
07c7343f94 | ||
|
|
530f751f02 | ||
|
|
9a005cabe9 | ||
|
|
f7eb502d9d | ||
|
|
a407cfb514 | ||
|
|
ff43d07b6d | ||
|
|
340b5f22b7 | ||
|
|
b4a90131bb | ||
|
|
90149ddb4e | ||
|
|
1f09f0cf68 | ||
|
|
8035e7aecb | ||
|
|
cea32deba2 | ||
|
|
b02358e3a0 | ||
|
|
79320f27c9 | ||
|
|
52ca2f7339 | ||
|
|
78e54248e3 | ||
|
|
fc82604947 | ||
|
|
40bb0feaf8 | ||
|
|
0afb6a9481 | ||
|
|
57f72a473f | ||
|
|
876fbb9980 | ||
|
|
bee09f7c29 | ||
|
|
c31aef4131 | ||
|
|
53a36e7974 | ||
|
|
60e74c4916 | ||
|
|
1d24f912ae | ||
|
|
f9591c512c | ||
|
|
f74396e97b | ||
|
|
1127eeebb8 | ||
|
|
e9590e8b04 | ||
|
|
fd0bc89771 | ||
|
|
32a38b46fe | ||
|
|
e5f9d8cfdf | ||
|
|
ecd6b30626 | ||
|
|
31da701fe7 | ||
|
|
9d875b3935 | ||
|
|
8cab4ffb42 | ||
|
|
61aeb5bf86 | ||
|
|
0821008d6e | ||
|
|
a4a24b77b9 | ||
|
|
897edab3cf |
@@ -2,7 +2,7 @@ import logging
|
||||
import uuid
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Body, Depends, Response, status
|
||||
from fastapi import APIRouter, Body, Depends, Query, Response, status
|
||||
from sqlmodel import Session
|
||||
|
||||
import inse.auth.service as auth_service
|
||||
@@ -204,3 +204,30 @@ async def change_password(
|
||||
current_password=current_password,
|
||||
new_password=new_password,
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/can-fetch-gdpr-relevant-data",
|
||||
summary="Check if user can fetch GDPR-relevant data",
|
||||
description="Check if the authenticated user can fetch GDPR-relevant data for a given author and institution.",
|
||||
operation_id="canFetchGdprRelevantData",
|
||||
)
|
||||
async def can_fetch_gdpr_relevant_data(
|
||||
access_token: Annotated[
|
||||
AccessTokenMetadata,
|
||||
auth_service.CurrentUserAccessTokenPayloadDep,
|
||||
],
|
||||
raw_oa_author_id: Annotated[
|
||||
str | None,
|
||||
Query(description="OpenAlex author ID to check access for"),
|
||||
] = None,
|
||||
raw_oa_institution_id: Annotated[
|
||||
str | None,
|
||||
Query(description="OpenAlex institution ID to check access for"),
|
||||
] = None,
|
||||
) -> bool:
|
||||
return await auth_service.can_fetch_gdpr_relevant_data(
|
||||
access_token=access_token,
|
||||
raw_oa_author_id=raw_oa_author_id,
|
||||
raw_oa_institution_id=raw_oa_institution_id,
|
||||
)
|
||||
|
||||
@@ -31,6 +31,7 @@ from inse.auth.model import (
|
||||
effective_role_for_roles,
|
||||
normalize_roles,
|
||||
)
|
||||
from inse.authors.v2 import service as authors_service
|
||||
from inse.config import get_settings
|
||||
from inse.database import get_session
|
||||
|
||||
@@ -1451,3 +1452,69 @@ def change_password(
|
||||
logger.info("Password changed successfully for account %s", account.id)
|
||||
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
async def can_fetch_gdpr_relevant_data(
|
||||
access_token: AccessTokenMetadata,
|
||||
raw_oa_author_id: str | None = None,
|
||||
raw_oa_institution_id: str | None = None,
|
||||
) -> bool:
|
||||
"""Returns True if the user associated with the provided access token is allowed to fetch GDPR-relevant data for the specified OpenAlex author ID and institution ID, based on their effective institution ID.
|
||||
|
||||
Args:
|
||||
access_token (AccessTokenMetadata): The access token for the user.
|
||||
raw_oa_author_id (str | None, optional): The OpenAlex author ID for which to check access. Defaults to None.
|
||||
raw_oa_institution_id (str | None, optional): The OpenAlex institution ID for which to check access. Defaults to None.
|
||||
|
||||
Returns:
|
||||
bool: True if the user is allowed to fetch GDPR-relevant data for the specified IDs, False otherwise.
|
||||
"""
|
||||
|
||||
logger.debug(
|
||||
"Checking if user with effective institution ID %s can fetch GDPR-relevant data for author ID %s and institution ID %s",
|
||||
access_token.effective_institution_id,
|
||||
raw_oa_author_id,
|
||||
raw_oa_institution_id,
|
||||
)
|
||||
|
||||
if not raw_oa_author_id and not raw_oa_institution_id:
|
||||
logger.debug("No OpenAlex author ID or institution ID provided")
|
||||
return False
|
||||
|
||||
effective_institution_id = access_token.effective_institution_id
|
||||
# Current user does not belong to any institution
|
||||
if not effective_institution_id:
|
||||
logger.debug(
|
||||
"Current user does not belong to any institution, cannot fetch GDPR-relevant data"
|
||||
)
|
||||
return False
|
||||
|
||||
# Current user belongs to an institution, but the request is for a different institution
|
||||
if (
|
||||
raw_oa_institution_id
|
||||
and effective_institution_id
|
||||
and raw_oa_institution_id != effective_institution_id
|
||||
):
|
||||
logger.debug(
|
||||
"Current user belongs to institution %s, but request is for institution %s, cannot fetch GDPR-relevant data",
|
||||
effective_institution_id,
|
||||
raw_oa_institution_id,
|
||||
)
|
||||
return False
|
||||
|
||||
# Current user belongs to an institution, but request is for author not belonging to that institution
|
||||
if raw_oa_author_id:
|
||||
author_belongs_to_institution = (
|
||||
await authors_service.author_currently_belongs_to_institution(
|
||||
raw_oa_author_id or "", effective_institution_id
|
||||
)
|
||||
)
|
||||
logger.debug(
|
||||
"Author %s belongs to institution %s: %s",
|
||||
raw_oa_author_id,
|
||||
effective_institution_id,
|
||||
author_belongs_to_institution,
|
||||
)
|
||||
return author_belongs_to_institution
|
||||
|
||||
return True
|
||||
|
||||
@@ -11,13 +11,13 @@ from sqlmodel import Session
|
||||
|
||||
from inse import config
|
||||
from inse.auth.model import AccessToken, Organization
|
||||
from inse.authors.institution_membership_query import (
|
||||
build_institution_membership_query,
|
||||
)
|
||||
from inse.institutions.institutions_search_client import InstitutionsSearchClient
|
||||
from inse.institutions.v2 import service as institutions_v2_service
|
||||
from inse.integrations import elasticsearch
|
||||
from inse.model import ESCluster, ESIndex
|
||||
from inse.patents.org.elastic_search_client import OrgPatentsSearchClient
|
||||
from inse.persons import service as persons_service
|
||||
from inse.projects import service as projects_service
|
||||
from inse.projects.dfg_institutions.service import (
|
||||
autocomplete_institutions_for_selector,
|
||||
)
|
||||
@@ -30,6 +30,7 @@ from inse.projects.model import (
|
||||
ProjectsFilteringProperties,
|
||||
ProjectType,
|
||||
)
|
||||
from inse.works.v2 import service as works_v2_service
|
||||
|
||||
from .institute_helper import get_openalex_institution
|
||||
from .model import (
|
||||
@@ -241,20 +242,32 @@ async def get_dashboard_publications(
|
||||
) -> DashboardStatisticValue:
|
||||
normalized_id = _normalize_institution_id(institution_id)
|
||||
period = _dashboard_period(from_year, to_year)
|
||||
filters = []
|
||||
if year_filter := _publication_year_filter(period):
|
||||
filters.append(year_filter)
|
||||
query = _institution_works_query(normalized_id)
|
||||
if filters:
|
||||
query = {"bool": {"must": [query], "filter": filters}}
|
||||
must = [
|
||||
works_v2_service._institutions_nested_query([normalized_id]),
|
||||
]
|
||||
if publication_years := _dashboard_publication_years(period):
|
||||
must.append({"terms": {"publication_year": publication_years}})
|
||||
response = await elasticsearch.search(
|
||||
index=config.settings.openalex_works_search_index,
|
||||
query=query,
|
||||
size=0,
|
||||
track_total_hits=True,
|
||||
index=ESIndex.OPENALEX_WORKS_WILDCARD,
|
||||
body={
|
||||
"size": 0,
|
||||
"track_total_hits": True,
|
||||
"query": {"bool": {"must": must}},
|
||||
},
|
||||
cluster=ESCluster.NES,
|
||||
)
|
||||
return _dashboard_statistic_value(normalized_id, organization_name, response)
|
||||
return DashboardStatisticValue(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
value=_total(response),
|
||||
)
|
||||
|
||||
|
||||
def _dashboard_publication_years(period: DashboardPeriod) -> list[int] | None:
|
||||
from_year, to_year = period
|
||||
if from_year is None and to_year is None:
|
||||
return None
|
||||
return list(range(from_year or 1900, (to_year or 2100) + 1))
|
||||
|
||||
|
||||
async def get_dashboard_persons(
|
||||
@@ -270,20 +283,25 @@ async def get_dashboard_persons(
|
||||
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
|
||||
detail="from_year and to_year must either both be provided or both omitted.",
|
||||
)
|
||||
membership_query = build_institution_membership_query(
|
||||
persons = await persons_service.search_persons_list(
|
||||
query=None,
|
||||
institution_id=normalized_id,
|
||||
year_mode="between" if period[0] is not None else "all",
|
||||
year=period[0],
|
||||
year_to=period[1],
|
||||
sort_by=None,
|
||||
sort_order=None,
|
||||
topic=None,
|
||||
page=1,
|
||||
page_size=1,
|
||||
include="",
|
||||
year_filter_enabled=period[0] is not None,
|
||||
filter_mode="between" if period[0] is not None else None,
|
||||
filter_year=period[0],
|
||||
filter_year_to=period[1],
|
||||
)
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.OPENALEX_AUTHORS,
|
||||
query=membership_query,
|
||||
size=0,
|
||||
track_total_hits=True,
|
||||
cluster=ESCluster.NES,
|
||||
return DashboardStatisticValue(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
value=int(persons.meta.count or 0) if persons.meta else 0,
|
||||
)
|
||||
return _dashboard_statistic_value(normalized_id, organization_name, response)
|
||||
|
||||
|
||||
async def get_dashboard_patents(
|
||||
@@ -315,45 +333,43 @@ async def get_dashboard_eu_projects(
|
||||
to_year: int | None = None,
|
||||
) -> DashboardStatisticValue:
|
||||
normalized_id = _normalize_institution_id(institution_id)
|
||||
aliases = await _institution_aliases(normalized_id, organization_name)
|
||||
period = _dashboard_period(from_year, to_year)
|
||||
period_filter = _project_overlap_filter(
|
||||
"startDate",
|
||||
"endDate",
|
||||
_date_period(period, "iso"),
|
||||
)
|
||||
if period_filter:
|
||||
project_ids = await _eu_project_ids_for_aliases(aliases)
|
||||
value = await _count_eu_projects_in_period(project_ids, period_filter)
|
||||
return DashboardStatisticValue(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
value=value,
|
||||
)
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD,
|
||||
body={
|
||||
"size": 0,
|
||||
"query": _eu_organization_query(aliases),
|
||||
"aggs": {
|
||||
"projects": {
|
||||
"cardinality": {
|
||||
"field": "projectID",
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
cluster=ESCluster.INSE,
|
||||
projects = await projects_service.search_eu_cordis_projects(
|
||||
institutions_search_client=InstitutionsSearchClient(),
|
||||
raw_oa_institution_id=_raw_institution_id(normalized_id),
|
||||
author_id=None,
|
||||
author_ids=None,
|
||||
organization_ids=None,
|
||||
organization_names=None,
|
||||
project_types=list(EuCordisProjectType),
|
||||
keywords=None,
|
||||
topic_ids=None,
|
||||
filter_topic_ids=None,
|
||||
title=None,
|
||||
funding_start_years=(
|
||||
[str(year) for year in range(1900, period[1] + 1)]
|
||||
if period[1] is not None
|
||||
else None
|
||||
),
|
||||
funding_end_years=(
|
||||
[str(year) for year in range(period[0], 2101)]
|
||||
if period[0] is not None
|
||||
else None
|
||||
),
|
||||
countries=None,
|
||||
framework_programmes=None,
|
||||
funding_schemes=None,
|
||||
statuses=None,
|
||||
page=0,
|
||||
size=1,
|
||||
sort_by="id",
|
||||
sort_direction="asc",
|
||||
fuzzy=False,
|
||||
)
|
||||
return DashboardStatisticValue(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
value=int(
|
||||
response.get("aggregations", {})
|
||||
.get("projects", {})
|
||||
.get("value", 0)
|
||||
),
|
||||
value=projects.total,
|
||||
)
|
||||
|
||||
|
||||
@@ -368,10 +384,18 @@ async def get_dashboard_eu_project_statuses(
|
||||
project_ids = await _eu_project_ids_for_aliases(aliases)
|
||||
|
||||
if not project_ids:
|
||||
total = (
|
||||
await get_dashboard_eu_projects(
|
||||
normalized_id,
|
||||
organization_name,
|
||||
from_year=from_year,
|
||||
to_year=to_year,
|
||||
)
|
||||
).value
|
||||
return EuProjectStatusStatistics(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
ongoing=0,
|
||||
ongoing=total,
|
||||
upcoming=0,
|
||||
completed=0,
|
||||
)
|
||||
@@ -426,12 +450,26 @@ async def get_dashboard_eu_project_statuses(
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
aggregations = response.get("aggregations", {})
|
||||
total = (
|
||||
await get_dashboard_eu_projects(
|
||||
normalized_id,
|
||||
organization_name,
|
||||
from_year=from_year,
|
||||
to_year=to_year,
|
||||
)
|
||||
).value
|
||||
ongoing, upcoming, completed = _reconcile_project_status_counts(
|
||||
total,
|
||||
_project_status_count(aggregations, "ongoing"),
|
||||
_project_status_count(aggregations, "upcoming"),
|
||||
_project_status_count(aggregations, "completed"),
|
||||
)
|
||||
return EuProjectStatusStatistics(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
ongoing=_project_status_count(aggregations, "ongoing"),
|
||||
upcoming=_project_status_count(aggregations, "upcoming"),
|
||||
completed=_project_status_count(aggregations, "completed"),
|
||||
ongoing=ongoing,
|
||||
upcoming=upcoming,
|
||||
completed=completed,
|
||||
)
|
||||
|
||||
|
||||
@@ -441,6 +479,32 @@ def _project_status_count(aggregations: dict[str, Any], status_name: str) -> int
|
||||
)
|
||||
|
||||
|
||||
def _reconcile_project_status_counts(
|
||||
total: int,
|
||||
ongoing: int,
|
||||
upcoming: int,
|
||||
completed: int,
|
||||
) -> tuple[int, int, int]:
|
||||
"""Makes status buckets add up to the authoritative project-service total."""
|
||||
counts = [max(0, ongoing), max(0, upcoming), max(0, completed)]
|
||||
difference = total - sum(counts)
|
||||
if difference >= 0:
|
||||
counts[0] += difference
|
||||
return counts[0], counts[1], counts[2]
|
||||
|
||||
# Defensive fallback for stale/duplicated status documents: reduce buckets
|
||||
# without ever returning negative values, preferring the inferred ongoing
|
||||
# bucket before changing explicit upcoming/completed classifications.
|
||||
excess = -difference
|
||||
for index in (0, 1, 2):
|
||||
reduction = min(counts[index], excess)
|
||||
counts[index] -= reduction
|
||||
excess -= reduction
|
||||
if excess == 0:
|
||||
break
|
||||
return counts[0], counts[1], counts[2]
|
||||
|
||||
|
||||
async def get_dashboard_bmbf_projects(
|
||||
institution_id: str,
|
||||
organization_name: str,
|
||||
@@ -448,23 +512,38 @@ async def get_dashboard_bmbf_projects(
|
||||
to_year: int | None = None,
|
||||
) -> DashboardStatisticValue:
|
||||
normalized_id = _normalize_institution_id(institution_id)
|
||||
aliases = await _institution_aliases(normalized_id, organization_name)
|
||||
period = _dashboard_period(from_year, to_year)
|
||||
filters = [_alias_match_query("Zuwendungsempfänger", aliases)]
|
||||
if period_filter := _project_overlap_filter(
|
||||
"funding_start",
|
||||
"funding_end",
|
||||
_date_period(period, "de"),
|
||||
):
|
||||
filters.append(period_filter)
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.PROJECTS_BUND_V1,
|
||||
query=filters[0] if len(filters) == 1 else {"bool": {"filter": filters}},
|
||||
size=0,
|
||||
track_total_hits=True,
|
||||
cluster=ESCluster.INSE,
|
||||
projects = await projects_service.search_bund_projects_with_filters(
|
||||
institutions_search_client=InstitutionsSearchClient(),
|
||||
executing_agency=None,
|
||||
raw_oa_institution_id=_raw_institution_id(normalized_id),
|
||||
title=None,
|
||||
keywords=None,
|
||||
funding_arts=None,
|
||||
topic_ids=None,
|
||||
filter_topic_ids=None,
|
||||
funding_start_years=(
|
||||
[str(year) for year in range(1900, period[1] + 1)]
|
||||
if period[1] is not None
|
||||
else None
|
||||
),
|
||||
funding_end_years=(
|
||||
[str(year) for year in range(period[0], 2101)]
|
||||
if period[0] is not None
|
||||
else None
|
||||
),
|
||||
countries=None,
|
||||
page=0,
|
||||
size=1,
|
||||
sort_by="id",
|
||||
sort_direction="asc",
|
||||
fuzzy=False,
|
||||
)
|
||||
return DashboardStatisticValue(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
value=projects.total,
|
||||
)
|
||||
return _dashboard_statistic_value(normalized_id, organization_name, response)
|
||||
|
||||
|
||||
async def get_dashboard_bmbf_project_statuses(
|
||||
@@ -498,12 +577,26 @@ async def get_dashboard_bmbf_project_statuses(
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
aggregations = response.get("aggregations", {})
|
||||
total = (
|
||||
await get_dashboard_bmbf_projects(
|
||||
normalized_id,
|
||||
organization_name,
|
||||
from_year=from_year,
|
||||
to_year=to_year,
|
||||
)
|
||||
).value
|
||||
ongoing, upcoming, completed = _reconcile_project_status_counts(
|
||||
total,
|
||||
int(aggregations.get("ongoing", {}).get("doc_count", 0)),
|
||||
int(aggregations.get("upcoming", {}).get("doc_count", 0)),
|
||||
int(aggregations.get("completed", {}).get("doc_count", 0)),
|
||||
)
|
||||
return BmbfProjectStatusStatistics(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
ongoing=int(aggregations.get("ongoing", {}).get("doc_count", 0)),
|
||||
upcoming=int(aggregations.get("upcoming", {}).get("doc_count", 0)),
|
||||
completed=int(aggregations.get("completed", {}).get("doc_count", 0)),
|
||||
ongoing=ongoing,
|
||||
upcoming=upcoming,
|
||||
completed=completed,
|
||||
)
|
||||
|
||||
|
||||
@@ -535,15 +628,37 @@ async def get_dashboard_dfg_projects(
|
||||
to_year: int | None = None,
|
||||
) -> DashboardStatisticValue:
|
||||
normalized_id = _normalize_institution_id(institution_id)
|
||||
project_ids = await _get_dfg_project_ids_for_institution(
|
||||
normalized_id,
|
||||
from_year=from_year,
|
||||
to_year=to_year,
|
||||
period = _dashboard_period(from_year, to_year)
|
||||
projects = await projects_service.get_dfg_projects_by_author_id(
|
||||
institutions_search_client=InstitutionsSearchClient(),
|
||||
raw_oa_institution_id=_raw_institution_id(normalized_id),
|
||||
author_id=None,
|
||||
author_filter_ids=None,
|
||||
institution_ids=None,
|
||||
keywords=None,
|
||||
topic_ids=None,
|
||||
filter_topic_ids=None,
|
||||
title=None,
|
||||
funding_start_years=(
|
||||
[str(year) for year in range(1900, period[1] + 1)]
|
||||
if period[1] is not None
|
||||
else None
|
||||
),
|
||||
funding_end_years=(
|
||||
[str(year) for year in range(period[0], 2101)]
|
||||
if period[0] is not None
|
||||
else None
|
||||
),
|
||||
page=0,
|
||||
size=1,
|
||||
sort_by="id",
|
||||
sort_direction="asc",
|
||||
fuzzy=False,
|
||||
)
|
||||
return DashboardStatisticValue(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
value=len(project_ids),
|
||||
value=projects.total,
|
||||
)
|
||||
|
||||
|
||||
@@ -559,10 +674,18 @@ async def get_dashboard_dfg_project_statuses(
|
||||
normalized_id,
|
||||
)
|
||||
if not project_ids:
|
||||
total = (
|
||||
await get_dashboard_dfg_projects(
|
||||
normalized_id,
|
||||
organization_name,
|
||||
from_year=from_year,
|
||||
to_year=to_year,
|
||||
)
|
||||
).value
|
||||
return DfgProjectStatusStatistics(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
ongoing=0,
|
||||
ongoing=total,
|
||||
upcoming=0,
|
||||
completed=0,
|
||||
)
|
||||
@@ -640,12 +763,26 @@ async def get_dashboard_dfg_project_statuses(
|
||||
.get("projects_nested", {})
|
||||
.get("selected_projects", {})
|
||||
)
|
||||
total = (
|
||||
await get_dashboard_dfg_projects(
|
||||
normalized_id,
|
||||
organization_name,
|
||||
from_year=from_year,
|
||||
to_year=to_year,
|
||||
)
|
||||
).value
|
||||
ongoing, upcoming, completed = _reconcile_project_status_counts(
|
||||
total,
|
||||
_project_status_count(aggregations, "ongoing"),
|
||||
0,
|
||||
_project_status_count(aggregations, "completed"),
|
||||
)
|
||||
return DfgProjectStatusStatistics(
|
||||
institution_id=normalized_id,
|
||||
organization_name=organization_name,
|
||||
ongoing=_project_status_count(aggregations, "ongoing"),
|
||||
upcoming=0,
|
||||
completed=_project_status_count(aggregations, "completed"),
|
||||
ongoing=ongoing,
|
||||
upcoming=upcoming,
|
||||
completed=completed,
|
||||
)
|
||||
|
||||
|
||||
@@ -656,17 +793,11 @@ async def get_dashboard_dfg_topics(
|
||||
to_year: int | None = None,
|
||||
) -> DfgProjectTopics:
|
||||
normalized_id = _normalize_institution_id(institution_id)
|
||||
project_ids = await _get_dfg_project_ids_for_institution(
|
||||
project_ids = await _get_dfg_project_ids_from_projects_service(
|
||||
normalized_id,
|
||||
from_year=from_year,
|
||||
to_year=to_year,
|
||||
)
|
||||
print(
|
||||
"Dashboard DFG project topics "
|
||||
f"for institution {normalized_id}: "
|
||||
f"{len(project_ids)} project IDs={project_ids}",
|
||||
flush=True,
|
||||
)
|
||||
topics: dict[str, dict[str, Any]] = {}
|
||||
matched_project_ids: set[str] = set()
|
||||
|
||||
@@ -735,6 +866,53 @@ async def get_dashboard_dfg_topics(
|
||||
)
|
||||
|
||||
|
||||
async def _get_dfg_project_ids_from_projects_service(
|
||||
institution_id: str,
|
||||
from_year: int | None = None,
|
||||
to_year: int | None = None,
|
||||
) -> list[str]:
|
||||
"""Returns every matching DFG project ID through the canonical project service."""
|
||||
period = _dashboard_period(from_year, to_year)
|
||||
page_size = 1000
|
||||
page_number = 0
|
||||
project_ids: set[str] = set()
|
||||
|
||||
while True:
|
||||
projects = await projects_service.get_dfg_projects_by_author_id(
|
||||
institutions_search_client=InstitutionsSearchClient(),
|
||||
raw_oa_institution_id=_raw_institution_id(institution_id),
|
||||
author_id=None,
|
||||
author_filter_ids=None,
|
||||
institution_ids=None,
|
||||
keywords=None,
|
||||
topic_ids=None,
|
||||
filter_topic_ids=None,
|
||||
title=None,
|
||||
funding_start_years=(
|
||||
[str(year) for year in range(1900, period[1] + 1)]
|
||||
if period[1] is not None
|
||||
else None
|
||||
),
|
||||
funding_end_years=(
|
||||
[str(year) for year in range(period[0], 2101)]
|
||||
if period[0] is not None
|
||||
else None
|
||||
),
|
||||
page=page_number,
|
||||
size=page_size,
|
||||
sort_by="id",
|
||||
sort_direction="asc",
|
||||
fuzzy=False,
|
||||
skip_enrichment=True,
|
||||
)
|
||||
project_ids.update(project.id for project in projects.elements if project.id)
|
||||
if len(project_ids) >= projects.total or not projects.elements:
|
||||
break
|
||||
page_number += 1
|
||||
|
||||
return sorted(project_ids)
|
||||
|
||||
|
||||
async def _get_dfg_project_ids_for_institution(
|
||||
institution_id: str,
|
||||
from_year: int | None = None,
|
||||
@@ -1011,9 +1189,11 @@ async def get_top_authors(
|
||||
from_year = datetime.now().year - 4
|
||||
to_year = datetime.now().year
|
||||
period = _dashboard_period(from_year, to_year)
|
||||
aliases = await _institution_aliases(normalized_id, organization_name)
|
||||
authors = await _safe_institution_authors(normalized_id)
|
||||
works = _top_work_authors(authors, period)
|
||||
works = await _safe_top_authors(
|
||||
"works",
|
||||
_top_work_authors(normalized_id, period, authors),
|
||||
)
|
||||
projects = await _safe_top_authors(
|
||||
"projects",
|
||||
_top_project_authors(
|
||||
@@ -1025,7 +1205,12 @@ async def get_top_authors(
|
||||
)
|
||||
eu_projects = await _safe_top_authors(
|
||||
"eu_projects",
|
||||
_top_eu_project_publication_authors(normalized_id, aliases, authors),
|
||||
_top_eu_project_publication_authors(
|
||||
normalized_id,
|
||||
authors,
|
||||
from_year=period[0],
|
||||
to_year=period[1],
|
||||
),
|
||||
)
|
||||
|
||||
patents = await _safe_top_authors(
|
||||
@@ -1420,51 +1605,81 @@ def _short_author_id(value: str) -> str:
|
||||
return value.replace("https://openalex.org/", "").strip().upper()
|
||||
|
||||
|
||||
def _top_work_authors(
|
||||
authors: list[dict[str, Any]],
|
||||
async def _top_work_authors(
|
||||
institution_id: str,
|
||||
period: DashboardPeriod,
|
||||
institution_authors: list[dict[str, Any]],
|
||||
) -> list[TopAuthor]:
|
||||
if period != (None, None):
|
||||
ranked_authors = sorted(
|
||||
(
|
||||
{
|
||||
**author,
|
||||
"selected_works_count": _works_count_in_period(author, period),
|
||||
}
|
||||
for author in authors
|
||||
),
|
||||
key=lambda author: author["selected_works_count"],
|
||||
reverse=True,
|
||||
)
|
||||
else:
|
||||
ranked_authors = [
|
||||
{**author, "selected_works_count": author["works_count"]}
|
||||
for author in authors
|
||||
]
|
||||
institution_author_ids = {
|
||||
_short_author_id(str(author["id"]))
|
||||
for author in institution_authors
|
||||
if author.get("id")
|
||||
}
|
||||
if not institution_author_ids:
|
||||
return []
|
||||
|
||||
must = [works_v2_service._institutions_nested_query([institution_id])]
|
||||
if publication_years := _dashboard_publication_years(period):
|
||||
must.append({"terms": {"publication_year": publication_years}})
|
||||
|
||||
author_counts: dict[str, int] = defaultdict(int)
|
||||
author_names: dict[str, str] = {}
|
||||
async for hit in elasticsearch.scan(
|
||||
index=str(ESIndex.OPENALEX_WORKS_WILDCARD),
|
||||
query={"bool": {"must": must}},
|
||||
source=[
|
||||
"id",
|
||||
"authorships.author.id",
|
||||
"authorships.author.display_name",
|
||||
"authorships.institutions.id",
|
||||
],
|
||||
page_size=1000,
|
||||
cluster=ESCluster.NES,
|
||||
):
|
||||
hit_author_ids: set[str] = set()
|
||||
for authorship in hit.get("_source", {}).get("authorships", []):
|
||||
if not any(
|
||||
_normalize_institution_id(institution.get("id")) == institution_id
|
||||
for institution in authorship.get("institutions") or []
|
||||
if institution.get("id")
|
||||
):
|
||||
continue
|
||||
author = authorship.get("author") or {}
|
||||
author_id = author.get("id")
|
||||
if not author_id:
|
||||
continue
|
||||
author_id = str(author_id)
|
||||
if _short_author_id(author_id) not in institution_author_ids:
|
||||
continue
|
||||
hit_author_ids.add(author_id)
|
||||
if author.get("display_name"):
|
||||
author_names.setdefault(author_id, str(author["display_name"]))
|
||||
for author_id in hit_author_ids:
|
||||
author_counts[author_id] += 1
|
||||
|
||||
ranked_authors = sorted(
|
||||
(
|
||||
{
|
||||
"id": author_id,
|
||||
"name": author_names.get(author_id, author_id),
|
||||
"count": count,
|
||||
}
|
||||
for author_id, count in author_counts.items()
|
||||
),
|
||||
key=lambda author: author["count"],
|
||||
reverse=True,
|
||||
)
|
||||
return [
|
||||
TopAuthor(
|
||||
id=_short_author_id(author["id"]),
|
||||
name=author["name"],
|
||||
count=author["selected_works_count"],
|
||||
count=author["count"],
|
||||
)
|
||||
for author in ranked_authors[:TOP_AUTHOR_LIMIT]
|
||||
if author["selected_works_count"] > 0
|
||||
if author["count"] > 0
|
||||
]
|
||||
|
||||
|
||||
def _works_count_in_period(author: dict[str, Any], period: DashboardPeriod) -> int:
|
||||
from_year, to_year = period
|
||||
return sum(
|
||||
int(item.get("works_count", 0) or 0)
|
||||
for item in author.get("counts_by_year", [])
|
||||
if (
|
||||
(from_year is None or int(item.get("year", 0) or 0) >= from_year)
|
||||
and (to_year is None or int(item.get("year", 0) or 0) <= to_year)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def _safe_institution_authors(institution_id: str) -> list[dict[str, Any]]:
|
||||
try:
|
||||
return await _institution_authors(institution_id)
|
||||
@@ -1998,8 +2213,9 @@ async def _top_patent_authors(
|
||||
|
||||
async def _top_eu_project_publication_authors(
|
||||
institution_id: str,
|
||||
organization_names: list[str],
|
||||
institution_authors: list[dict[str, Any]],
|
||||
from_year: int | None = None,
|
||||
to_year: int | None = None,
|
||||
) -> list[TopAuthor]:
|
||||
institution_author_ids = {
|
||||
author_id
|
||||
@@ -2009,17 +2225,12 @@ async def _top_eu_project_publication_authors(
|
||||
if not institution_author_ids:
|
||||
return []
|
||||
|
||||
project_page = await get_eu_organization_project_contributions(
|
||||
organization_names=organization_names,
|
||||
projects_filtering_properties=ProjectsFilteringProperties(
|
||||
project_type=ProjectType.EU,
|
||||
page=0,
|
||||
size=10000,
|
||||
),
|
||||
project_ids = await _get_eu_project_ids_from_projects_service(
|
||||
institution_id,
|
||||
from_year=from_year,
|
||||
to_year=to_year,
|
||||
)
|
||||
|
||||
project_ids = [project.project_id for project in project_page.elements]
|
||||
|
||||
if not project_ids:
|
||||
return []
|
||||
|
||||
@@ -2028,11 +2239,7 @@ async def _top_eu_project_publication_authors(
|
||||
body={
|
||||
"size": 10000,
|
||||
"_source": ["projectID", "qaProcessedDoi"],
|
||||
"query": {
|
||||
"terms": {
|
||||
"projectID": project_ids,
|
||||
}
|
||||
},
|
||||
"query": {"terms": {"projectID": project_ids}},
|
||||
},
|
||||
cluster=ESCluster.INSE,
|
||||
)
|
||||
@@ -2066,12 +2273,83 @@ async def _top_eu_project_publication_authors(
|
||||
cluster=ESCluster.NES,
|
||||
)
|
||||
|
||||
return _openalex_work_authors_by_eu_projects(
|
||||
candidates = _openalex_work_authors_by_eu_projects(
|
||||
works_response,
|
||||
doi_project_ids,
|
||||
institution_id,
|
||||
institution_author_ids,
|
||||
limit=None,
|
||||
)
|
||||
counts = await asyncio.gather(
|
||||
*(
|
||||
_person_eu_project_count(
|
||||
candidate.id,
|
||||
from_year=from_year,
|
||||
to_year=to_year,
|
||||
)
|
||||
for candidate in candidates
|
||||
if candidate.id
|
||||
)
|
||||
)
|
||||
ranked = [
|
||||
TopAuthor(id=candidate.id, name=candidate.name, count=count)
|
||||
for candidate, count in zip(candidates, counts, strict=True)
|
||||
]
|
||||
ranked.sort(key=lambda author: (-author.count, author.name, author.id or ""))
|
||||
return ranked[:TOP_AUTHOR_LIMIT]
|
||||
|
||||
|
||||
async def _get_eu_project_ids_from_projects_service(
|
||||
institution_id: str,
|
||||
from_year: int | None = None,
|
||||
to_year: int | None = None,
|
||||
) -> list[str]:
|
||||
"""Loads all organization EU project IDs from the canonical project service."""
|
||||
period = _dashboard_period(from_year, to_year)
|
||||
page_size = 1000
|
||||
page_number = 0
|
||||
project_ids: set[str] = set()
|
||||
|
||||
while True:
|
||||
projects = await projects_service.search_eu_cordis_projects(
|
||||
institutions_search_client=InstitutionsSearchClient(),
|
||||
raw_oa_institution_id=_raw_institution_id(institution_id),
|
||||
author_id=None,
|
||||
author_ids=None,
|
||||
organization_ids=None,
|
||||
organization_names=None,
|
||||
project_types=list(EuCordisProjectType),
|
||||
keywords=None,
|
||||
topic_ids=None,
|
||||
filter_topic_ids=None,
|
||||
title=None,
|
||||
funding_start_years=(
|
||||
[str(year) for year in range(1900, period[1] + 1)]
|
||||
if period[1] is not None
|
||||
else None
|
||||
),
|
||||
funding_end_years=(
|
||||
[str(year) for year in range(period[0], 2101)]
|
||||
if period[0] is not None
|
||||
else None
|
||||
),
|
||||
countries=None,
|
||||
framework_programmes=None,
|
||||
funding_schemes=None,
|
||||
statuses=None,
|
||||
page=page_number,
|
||||
size=page_size,
|
||||
sort_by="id",
|
||||
sort_direction="asc",
|
||||
fuzzy=False,
|
||||
skip_enrichment=True,
|
||||
)
|
||||
project_ids.update(project.id for project in projects.elements if project.id)
|
||||
if len(project_ids) >= projects.total or not projects.elements:
|
||||
break
|
||||
page_number += 1
|
||||
|
||||
return sorted(project_ids)
|
||||
|
||||
|
||||
def _cordis_publication_doi_project_ids(
|
||||
@@ -2108,6 +2386,7 @@ def _openalex_work_authors_by_eu_projects(
|
||||
doi_project_ids: dict[str, set[str]],
|
||||
institution_id: str,
|
||||
institution_author_ids: set[str],
|
||||
limit: int | None = TOP_AUTHOR_LIMIT,
|
||||
) -> list[TopAuthor]:
|
||||
# Count unique CORDIS projects per author, not publications. Multiple works
|
||||
# (and therefore multiple DOIs) can belong to the same project ID.
|
||||
@@ -2143,14 +2422,58 @@ def _openalex_work_authors_by_eu_projects(
|
||||
key=lambda item: (-len(item[1]), author_names.get(item[0], ""), item[0]),
|
||||
)
|
||||
|
||||
return [
|
||||
authors = [
|
||||
TopAuthor(
|
||||
id=_short_author_id(author_id),
|
||||
name=author_names[author_id],
|
||||
count=len(project_ids),
|
||||
)
|
||||
for author_id, project_ids in ranked_authors[:TOP_AUTHOR_LIMIT]
|
||||
for author_id, project_ids in ranked_authors
|
||||
]
|
||||
return authors[:limit] if limit is not None else authors
|
||||
|
||||
|
||||
async def _person_eu_project_count(
|
||||
author_id: str,
|
||||
from_year: int | None = None,
|
||||
to_year: int | None = None,
|
||||
) -> int:
|
||||
"""Uses the same author-only EU project search as the person detail page."""
|
||||
period = _dashboard_period(from_year, to_year)
|
||||
projects = await projects_service.search_eu_cordis_projects(
|
||||
page=0,
|
||||
size=1,
|
||||
project_types=None,
|
||||
raw_oa_institution_id=None,
|
||||
institutions_search_client=None,
|
||||
author_id=_short_author_id(author_id),
|
||||
author_ids=None,
|
||||
organization_ids=None,
|
||||
organization_names=None,
|
||||
keywords=None,
|
||||
topic_ids=None,
|
||||
filter_topic_ids=None,
|
||||
title=None,
|
||||
funding_start_years=(
|
||||
[str(year) for year in range(1900, period[1] + 1)]
|
||||
if period[1] is not None
|
||||
else None
|
||||
),
|
||||
funding_end_years=(
|
||||
[str(year) for year in range(period[0], 2101)]
|
||||
if period[0] is not None
|
||||
else None
|
||||
),
|
||||
countries=None,
|
||||
framework_programmes=None,
|
||||
funding_schemes=None,
|
||||
statuses=None,
|
||||
sort_by="title",
|
||||
sort_direction="asc",
|
||||
fuzzy=False,
|
||||
skip_enrichment=True,
|
||||
)
|
||||
return projects.total
|
||||
|
||||
|
||||
def _normalize_author_id(value: Any) -> str | None:
|
||||
|
||||
@@ -10,7 +10,14 @@ from inse import config
|
||||
from inse.auth.model import AccessToken, Organization, UserRole
|
||||
from inse.dashboard.service import (
|
||||
_openalex_work_authors_by_eu_projects,
|
||||
_get_dfg_project_ids_from_projects_service,
|
||||
_reconcile_project_status_counts,
|
||||
get_dashboard_bmbf_projects,
|
||||
get_dashboard_dfg_projects,
|
||||
get_dashboard_eu_projects,
|
||||
get_dashboard_organization,
|
||||
get_dashboard_persons,
|
||||
get_dashboard_publications,
|
||||
get_dashboard_statistics,
|
||||
get_top_authors,
|
||||
get_topic_heatmap,
|
||||
@@ -18,6 +25,16 @@ from inse.dashboard.service import (
|
||||
)
|
||||
from inse.model import ESCluster, ESIndex
|
||||
from inse.models.openalex.institution import Institution
|
||||
from inse.models.openalex.meta import Meta
|
||||
from inse.persons.model import CustomAuthorsListResponse
|
||||
from inse.projects.model import (
|
||||
BundProjectPage,
|
||||
DfgProjectPage,
|
||||
DfgProjectSummary,
|
||||
EuCordisProjectSearchPage,
|
||||
EuCordisProjectSummary,
|
||||
EuCordisProjectType,
|
||||
)
|
||||
|
||||
ORG_INSTITUTION_ID = "https://openalex.org/I123"
|
||||
|
||||
@@ -27,6 +44,47 @@ def anyio_backend():
|
||||
return "asyncio"
|
||||
|
||||
|
||||
def test_project_status_counts_match_authoritative_total():
|
||||
assert _reconcile_project_status_counts(12, 4, 1, 5) == (6, 1, 5)
|
||||
assert _reconcile_project_status_counts(7, 4, 2, 3) == (2, 2, 3)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dfg_topic_project_ids_use_paginated_projects_service():
|
||||
pages = [
|
||||
DfgProjectPage(
|
||||
elements=[DfgProjectSummary(id="101"), DfgProjectSummary(id="102")],
|
||||
total=3,
|
||||
page=0,
|
||||
size=1000,
|
||||
),
|
||||
DfgProjectPage(
|
||||
elements=[DfgProjectSummary(id="103")],
|
||||
total=3,
|
||||
page=1,
|
||||
size=1000,
|
||||
),
|
||||
]
|
||||
|
||||
with patch(
|
||||
"inse.dashboard.service.projects_service.get_dfg_projects_by_author_id",
|
||||
new=AsyncMock(side_effect=pages),
|
||||
) as mocked_get_projects:
|
||||
project_ids = await _get_dfg_project_ids_from_projects_service(
|
||||
ORG_INSTITUTION_ID,
|
||||
from_year=2020,
|
||||
to_year=2022,
|
||||
)
|
||||
|
||||
assert project_ids == ["101", "102", "103"]
|
||||
assert mocked_get_projects.await_count == 2
|
||||
first_call = mocked_get_projects.await_args_list[0]
|
||||
assert first_call.kwargs["raw_oa_institution_id"] == "I123"
|
||||
assert first_call.kwargs["skip_enrichment"] is True
|
||||
assert first_call.kwargs["funding_start_years"][-1] == "2022"
|
||||
assert first_call.kwargs["funding_end_years"][0] == "2020"
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_statistics_counts_organization_data_and_all_projects():
|
||||
async def search(**kwargs):
|
||||
@@ -84,6 +142,33 @@ async def test_dashboard_statistics_counts_organization_data_and_all_projects():
|
||||
display_name_alternatives=["Example Universität"],
|
||||
)
|
||||
),
|
||||
), patch(
|
||||
"inse.dashboard.service.projects_service.get_dfg_projects_by_author_id",
|
||||
new=AsyncMock(
|
||||
return_value=DfgProjectPage(elements=[], total=3, page=0, size=1)
|
||||
),
|
||||
), patch(
|
||||
"inse.dashboard.service.projects_service.search_eu_cordis_projects",
|
||||
new=AsyncMock(
|
||||
return_value=EuCordisProjectSearchPage(
|
||||
elements=[], total=10, page=0, size=1
|
||||
)
|
||||
),
|
||||
), patch(
|
||||
"inse.dashboard.service.projects_service.search_bund_projects_with_filters",
|
||||
new=AsyncMock(
|
||||
return_value=BundProjectPage(elements=[], total=5, page=0, size=1)
|
||||
),
|
||||
), patch(
|
||||
"inse.dashboard.service.persons_service.search_persons_list",
|
||||
new=AsyncMock(
|
||||
return_value=CustomAuthorsListResponse(
|
||||
results=[], meta=Meta(count=35, page=1, per_page=1)
|
||||
)
|
||||
),
|
||||
), patch(
|
||||
"inse.dashboard.service.institutions_v2_service.get_institution_by_id_or_raise",
|
||||
new=AsyncMock(return_value=Institution(id=ORG_INSTITUTION_ID, works_count=120)),
|
||||
):
|
||||
result = await get_dashboard_statistics(
|
||||
ORG_INSTITUTION_ID,
|
||||
@@ -101,64 +186,162 @@ async def test_dashboard_statistics_counts_organization_data_and_all_projects():
|
||||
"bmbf_projects": 5,
|
||||
}
|
||||
|
||||
publication_call = next(
|
||||
call
|
||||
for call in mocked_search.await_args_list
|
||||
if call.kwargs["index"] == config.settings.openalex_works_search_index
|
||||
)
|
||||
assert publication_call.kwargs["query"]["nested"]["query"]["term"] == {
|
||||
"authorships.institutions.id": ORG_INSTITUTION_ID
|
||||
}
|
||||
|
||||
person_call = next(
|
||||
call
|
||||
for call in mocked_search.await_args_list
|
||||
if call.kwargs["index"] == ESIndex.OPENALEX_AUTHORS
|
||||
)
|
||||
person_query = person_call.kwargs["query"]
|
||||
affiliation = person_query["bool"]["should"][0]["bool"]["filter"][1]
|
||||
|
||||
assert affiliation["nested"]["path"] == "affiliations"
|
||||
assert affiliation["nested"]["query"]["bool"]["filter"][0] == {
|
||||
"term": {"affiliations.institution.id": ORG_INSTITUTION_ID}
|
||||
}
|
||||
eu_call = next(
|
||||
call
|
||||
for call in mocked_search.await_args_list
|
||||
if call.kwargs["index"] == ESIndex.CORDIS_EU_ORGANIZATIONS_WILDCARD
|
||||
)
|
||||
assert eu_call.kwargs["cluster"] == ESCluster.INSE
|
||||
assert eu_call.kwargs["body"]["query"] == {
|
||||
"terms": {
|
||||
"name.keyword": [
|
||||
"EXAMPLE ORG",
|
||||
"EXAMPLE UNI",
|
||||
"EXAMPLE UNIVERSITY",
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_publications_counts_matching_openalex_works():
|
||||
with patch(
|
||||
"inse.dashboard.service.elasticsearch.search",
|
||||
new=AsyncMock(
|
||||
side_effect=[
|
||||
{"hits": {"total": {"value": 250}}},
|
||||
{"hits": {"total": {"value": 22}}},
|
||||
]
|
||||
}
|
||||
}
|
||||
),
|
||||
) as mocked_search:
|
||||
all_time = await get_dashboard_publications(
|
||||
ORG_INSTITUTION_ID,
|
||||
"Example Org",
|
||||
)
|
||||
selected_period = await get_dashboard_publications(
|
||||
ORG_INSTITUTION_ID,
|
||||
"Example Org",
|
||||
from_year=2021,
|
||||
to_year=2022,
|
||||
)
|
||||
|
||||
bund_call = next(
|
||||
call
|
||||
for call in mocked_search.await_args_list
|
||||
if call.kwargs["index"] == ESIndex.PROJECTS_BUND_V1
|
||||
assert all_time.value == 250
|
||||
assert selected_period.value == 22
|
||||
all_time_body = mocked_search.await_args_list[0].kwargs["body"]
|
||||
selected_period_body = mocked_search.await_args_list[1].kwargs["body"]
|
||||
assert mocked_search.await_args_list[0].kwargs["index"] == (
|
||||
ESIndex.OPENALEX_WORKS_WILDCARD
|
||||
)
|
||||
assert bund_call.kwargs["cluster"] == ESCluster.INSE
|
||||
assert bund_call.kwargs["query"]["bool"]["minimum_should_match"] == 1
|
||||
assert bund_call.kwargs["query"]["bool"]["should"][0]["match"] == {
|
||||
"Zuwendungsempfänger": {
|
||||
"query": "Example Org",
|
||||
"operator": "and",
|
||||
assert all_time_body["track_total_hits"] is True
|
||||
assert all_time_body["query"]["bool"]["must"] == [
|
||||
{
|
||||
"nested": {
|
||||
"path": "authorships",
|
||||
"query": {
|
||||
"nested": {
|
||||
"path": "authorships.institutions",
|
||||
"query": {
|
||||
"terms": {
|
||||
"authorships.institutions.id": [ORG_INSTITUTION_ID]
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dfg_calls = [
|
||||
call
|
||||
for call in mocked_search.await_args_list
|
||||
if call.kwargs["index"] == ESIndex.DFG_INSTITUTES_V2
|
||||
]
|
||||
assert len(dfg_calls) == 2
|
||||
assert all(call.kwargs["cluster"] == ESCluster.INSE for call in dfg_calls)
|
||||
assert selected_period_body["query"]["bool"]["must"] == [
|
||||
all_time_body["query"]["bool"]["must"][0],
|
||||
{"terms": {"publication_year": [2021, 2022]}},
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_persons_uses_persons_service_for_organization():
|
||||
response = CustomAuthorsListResponse(
|
||||
results=[], meta=Meta(count=64, page=1, per_page=1)
|
||||
)
|
||||
|
||||
with patch(
|
||||
"inse.dashboard.service.persons_service.search_persons_list",
|
||||
new=AsyncMock(return_value=response),
|
||||
) as mocked_search_persons:
|
||||
result = await get_dashboard_persons(
|
||||
ORG_INSTITUTION_ID,
|
||||
"Example Org",
|
||||
from_year=2020,
|
||||
to_year=2023,
|
||||
)
|
||||
|
||||
assert result.value == 64
|
||||
call = mocked_search_persons.await_args
|
||||
assert call.kwargs["institution_id"] == ORG_INSTITUTION_ID
|
||||
assert call.kwargs["filter_mode"] == "between"
|
||||
assert call.kwargs["filter_year"] == 2020
|
||||
assert call.kwargs["filter_year_to"] == 2023
|
||||
assert call.kwargs["page"] == 1
|
||||
assert call.kwargs["page_size"] == 1
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_dfg_projects_uses_projects_service_total():
|
||||
project_page = DfgProjectPage(elements=[], total=42, page=0, size=1)
|
||||
|
||||
with patch(
|
||||
"inse.dashboard.service.projects_service.get_dfg_projects_by_author_id",
|
||||
new=AsyncMock(return_value=project_page),
|
||||
) as mocked_get_projects:
|
||||
result = await get_dashboard_dfg_projects(
|
||||
ORG_INSTITUTION_ID,
|
||||
"Example Org",
|
||||
from_year=2020,
|
||||
to_year=2022,
|
||||
)
|
||||
|
||||
assert result.value == 42
|
||||
mocked_get_projects.assert_awaited_once()
|
||||
call = mocked_get_projects.await_args
|
||||
assert call.kwargs["raw_oa_institution_id"] == "I123"
|
||||
assert call.kwargs["funding_start_years"][-1] == "2022"
|
||||
assert call.kwargs["funding_end_years"][0] == "2020"
|
||||
assert call.kwargs["page"] == 0
|
||||
assert call.kwargs["size"] == 1
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_bmbf_projects_uses_projects_service_total():
|
||||
project_page = BundProjectPage(elements=[], total=29, page=0, size=1)
|
||||
|
||||
with patch(
|
||||
"inse.dashboard.service.projects_service.search_bund_projects_with_filters",
|
||||
new=AsyncMock(return_value=project_page),
|
||||
) as mocked_get_projects:
|
||||
result = await get_dashboard_bmbf_projects(
|
||||
ORG_INSTITUTION_ID,
|
||||
"Example Org",
|
||||
from_year=2018,
|
||||
to_year=2020,
|
||||
)
|
||||
|
||||
assert result.value == 29
|
||||
mocked_get_projects.assert_awaited_once()
|
||||
call = mocked_get_projects.await_args
|
||||
assert call.kwargs["raw_oa_institution_id"] == "I123"
|
||||
assert call.kwargs["funding_start_years"][-1] == "2020"
|
||||
assert call.kwargs["funding_end_years"][0] == "2018"
|
||||
assert call.kwargs["page"] == 0
|
||||
assert call.kwargs["size"] == 1
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_dashboard_eu_projects_uses_projects_service_total():
|
||||
project_page = EuCordisProjectSearchPage(
|
||||
elements=[], total=37, page=0, size=1
|
||||
)
|
||||
|
||||
with patch(
|
||||
"inse.dashboard.service.projects_service.search_eu_cordis_projects",
|
||||
new=AsyncMock(return_value=project_page),
|
||||
) as mocked_get_projects:
|
||||
result = await get_dashboard_eu_projects(
|
||||
ORG_INSTITUTION_ID,
|
||||
"Example Org",
|
||||
from_year=2019,
|
||||
to_year=2021,
|
||||
)
|
||||
|
||||
assert result.value == 37
|
||||
mocked_get_projects.assert_awaited_once()
|
||||
call = mocked_get_projects.await_args
|
||||
assert call.kwargs["raw_oa_institution_id"] == "I123"
|
||||
assert call.kwargs["funding_start_years"][-1] == "2021"
|
||||
assert call.kwargs["funding_end_years"][0] == "2019"
|
||||
assert call.kwargs["project_types"] == list(EuCordisProjectType)
|
||||
assert call.kwargs["page"] == 0
|
||||
assert call.kwargs["size"] == 1
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
@@ -272,23 +455,79 @@ async def test_top_authors_maps_works_patents_news_and_eu_projects():
|
||||
|
||||
return {"aggregations": {"people": {"buckets": []}}}
|
||||
|
||||
scan_calls = []
|
||||
|
||||
async def scan(**kwargs):
|
||||
scan_calls.append(kwargs)
|
||||
yield {
|
||||
"_id": "W1",
|
||||
"_source": {
|
||||
"id": "https://openalex.org/W1",
|
||||
"authorships": [
|
||||
{
|
||||
"author": {
|
||||
"id": "https://openalex.org/A1",
|
||||
"display_name": "Ada Example",
|
||||
},
|
||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
||||
},
|
||||
{
|
||||
"author": {
|
||||
"id": "https://openalex.org/A2",
|
||||
"display_name": "Grace Example",
|
||||
},
|
||||
"institutions": [{"id": "https://openalex.org/I999"}],
|
||||
},
|
||||
],
|
||||
},
|
||||
}
|
||||
yield {
|
||||
"_id": "W2",
|
||||
"_source": {
|
||||
"id": "https://openalex.org/W2",
|
||||
"authorships": [
|
||||
{
|
||||
"author": {
|
||||
"id": "https://openalex.org/A1",
|
||||
"display_name": "Ada Example",
|
||||
},
|
||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
||||
}
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
async def eu_projects(**kwargs):
|
||||
if kwargs.get("raw_oa_institution_id"):
|
||||
return EuCordisProjectSearchPage(
|
||||
elements=[
|
||||
EuCordisProjectSummary(id="P1", project_type=EuCordisProjectType.FP7),
|
||||
EuCordisProjectSummary(id="P2", project_type=EuCordisProjectType.H2020),
|
||||
EuCordisProjectSummary(id="P3", project_type=EuCordisProjectType.HEU),
|
||||
],
|
||||
total=3,
|
||||
page=0,
|
||||
size=1000,
|
||||
)
|
||||
return EuCordisProjectSearchPage(
|
||||
elements=[],
|
||||
total={"A1": 3, "A2": 4}[kwargs["author_id"]],
|
||||
page=0,
|
||||
size=1,
|
||||
)
|
||||
|
||||
with patch(
|
||||
"inse.dashboard.service.elasticsearch.search",
|
||||
new=AsyncMock(side_effect=search),
|
||||
) as mocked_search, patch(
|
||||
"inse.dashboard.service.elasticsearch.scan",
|
||||
new=scan,
|
||||
), patch(
|
||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||
new=AsyncMock(return_value=["Example University"]),
|
||||
), patch(
|
||||
"inse.dashboard.service.get_eu_organization_project_contributions",
|
||||
new=AsyncMock(
|
||||
return_value=SimpleNamespace(
|
||||
elements=[
|
||||
SimpleNamespace(project_id="P1"),
|
||||
SimpleNamespace(project_id="P2"),
|
||||
SimpleNamespace(project_id="P3"),
|
||||
],
|
||||
)
|
||||
),
|
||||
"inse.dashboard.service.projects_service.search_eu_cordis_projects",
|
||||
new=AsyncMock(side_effect=eu_projects),
|
||||
), patch(
|
||||
"inse.dashboard.service.OrgPatentsSearchClient.top_authors_by_institution",
|
||||
new=AsyncMock(
|
||||
@@ -305,16 +544,17 @@ async def test_top_authors_maps_works_patents_news_and_eu_projects():
|
||||
assert result.works[0].model_dump() == {
|
||||
"id": "A1",
|
||||
"name": "Ada Example",
|
||||
"count": 42,
|
||||
"count": 2,
|
||||
}
|
||||
assert len(result.works) == 1
|
||||
assert result.patents[0].model_dump() == {
|
||||
"id": "A1",
|
||||
"name": "Ada Example",
|
||||
"count": 4,
|
||||
}
|
||||
assert [author.model_dump() for author in result.eu_projects] == [
|
||||
{"id": "A2", "name": "Grace Example", "count": 2},
|
||||
{"id": "A1", "name": "Ada Example", "count": 1},
|
||||
{"id": "A2", "name": "Grace Example", "count": 4},
|
||||
{"id": "A1", "name": "Ada Example", "count": 3},
|
||||
]
|
||||
assert result.news[0].model_dump() == {
|
||||
"id": "A1",
|
||||
@@ -346,18 +586,44 @@ async def test_top_authors_maps_works_patents_news_and_eu_projects():
|
||||
assert eu_body["_source"] == ["projectID", "qaProcessedDoi"]
|
||||
assert "aggs" not in eu_body
|
||||
|
||||
works_calls = [
|
||||
assert len(scan_calls) == 1
|
||||
assert scan_calls[0]["index"] == str(ESIndex.OPENALEX_WORKS_WILDCARD)
|
||||
assert scan_calls[0]["query"]["bool"]["must"] == [
|
||||
{
|
||||
"nested": {
|
||||
"path": "authorships",
|
||||
"query": {
|
||||
"nested": {
|
||||
"path": "authorships.institutions",
|
||||
"query": {
|
||||
"terms": {
|
||||
"authorships.institutions.id": [ORG_INSTITUTION_ID]
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
]
|
||||
assert scan_calls[0]["source"] == [
|
||||
"id",
|
||||
"authorships.author.id",
|
||||
"authorships.author.display_name",
|
||||
"authorships.institutions.id",
|
||||
]
|
||||
|
||||
eu_work_calls = [
|
||||
call
|
||||
for call in mocked_search.await_args_list
|
||||
if call.kwargs["index"] == "openalex-works"
|
||||
]
|
||||
assert len(works_calls) == 1
|
||||
works_body = works_calls[0].kwargs["body"]
|
||||
assert works_body["query"]["bool"]["filter"][0]["terms"]["doi"] == [
|
||||
assert len(eu_work_calls) == 1
|
||||
eu_works_body = eu_work_calls[0].kwargs["body"]
|
||||
assert eu_works_body["query"]["bool"]["filter"][0]["terms"]["doi"] == [
|
||||
"https://doi.org/10.1234/p1",
|
||||
"https://doi.org/10.1234/p2",
|
||||
]
|
||||
assert works_body["_source"] == [
|
||||
assert eu_works_body["_source"] == [
|
||||
"doi",
|
||||
"authorships.author.id",
|
||||
"authorships.author.display_name",
|
||||
@@ -573,6 +839,24 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i
|
||||
}
|
||||
return {"aggregations": {"authors": {"buckets": []}}}
|
||||
|
||||
async def eu_projects(**kwargs):
|
||||
if kwargs.get("raw_oa_institution_id"):
|
||||
return EuCordisProjectSearchPage(
|
||||
elements=[
|
||||
EuCordisProjectSummary(id="P1", project_type=EuCordisProjectType.FP7),
|
||||
EuCordisProjectSummary(id="P2", project_type=EuCordisProjectType.H2020),
|
||||
],
|
||||
total=2,
|
||||
page=0,
|
||||
size=1000,
|
||||
)
|
||||
return EuCordisProjectSearchPage(
|
||||
elements=[],
|
||||
total={"A1": 4, "A2": 1}[kwargs["author_id"]],
|
||||
page=0,
|
||||
size=1,
|
||||
)
|
||||
|
||||
with patch(
|
||||
"inse.dashboard.service.elasticsearch.search",
|
||||
new=AsyncMock(side_effect=search),
|
||||
@@ -580,15 +864,8 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i
|
||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||
new=AsyncMock(return_value=["Example University"]),
|
||||
), patch(
|
||||
"inse.dashboard.service.get_eu_organization_project_contributions",
|
||||
new=AsyncMock(
|
||||
return_value=SimpleNamespace(
|
||||
elements=[
|
||||
SimpleNamespace(project_id="P1"),
|
||||
SimpleNamespace(project_id="P2"),
|
||||
],
|
||||
)
|
||||
),
|
||||
"inse.dashboard.service.projects_service.search_eu_cordis_projects",
|
||||
new=AsyncMock(side_effect=eu_projects),
|
||||
), patch(
|
||||
"inse.dashboard.service.OrgPatentsSearchClient.top_authors_by_institution",
|
||||
new=AsyncMock(return_value=[]),
|
||||
@@ -599,7 +876,7 @@ async def test_top_eu_project_authors_count_filtered_projects_by_stable_author_i
|
||||
)
|
||||
|
||||
assert [author.model_dump() for author in result.eu_projects] == [
|
||||
{"id": "A1", "name": "Ada Example", "count": 2},
|
||||
{"id": "A1", "name": "Ada Example", "count": 4},
|
||||
{"id": "A2", "name": "Grace Example", "count": 1},
|
||||
]
|
||||
|
||||
@@ -625,9 +902,29 @@ async def test_top_authors_returns_partial_response_when_one_source_fails():
|
||||
|
||||
raise RuntimeError("projects unavailable")
|
||||
|
||||
async def scan(**kwargs):
|
||||
yield {
|
||||
"_id": "W1",
|
||||
"_source": {
|
||||
"id": "https://openalex.org/W1",
|
||||
"authorships": [
|
||||
{
|
||||
"author": {
|
||||
"id": "https://openalex.org/A1",
|
||||
"display_name": "Ada Example",
|
||||
},
|
||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
||||
}
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
with patch(
|
||||
"inse.dashboard.service.elasticsearch.search",
|
||||
new=AsyncMock(side_effect=search),
|
||||
), patch(
|
||||
"inse.dashboard.service.elasticsearch.scan",
|
||||
new=scan,
|
||||
), patch(
|
||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||
new=AsyncMock(return_value=["Example University"]),
|
||||
@@ -691,9 +988,47 @@ async def test_top_authors_can_rank_works_by_last_five_years():
|
||||
}
|
||||
return {"aggregations": {"people": {"buckets": []}}}
|
||||
|
||||
scan_calls = []
|
||||
|
||||
async def scan(**kwargs):
|
||||
scan_calls.append(kwargs)
|
||||
for index in range(16):
|
||||
yield {
|
||||
"_id": f"W-grace-{index}",
|
||||
"_source": {
|
||||
"authorships": [
|
||||
{
|
||||
"author": {
|
||||
"id": "https://openalex.org/A2",
|
||||
"display_name": "Grace Example",
|
||||
},
|
||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
for index in range(2):
|
||||
yield {
|
||||
"_id": f"W-ada-{index}",
|
||||
"_source": {
|
||||
"authorships": [
|
||||
{
|
||||
"author": {
|
||||
"id": "https://openalex.org/A1",
|
||||
"display_name": "Ada Example",
|
||||
},
|
||||
"institutions": [{"id": ORG_INSTITUTION_ID}],
|
||||
}
|
||||
]
|
||||
},
|
||||
}
|
||||
|
||||
with patch(
|
||||
"inse.dashboard.service.elasticsearch.search",
|
||||
new=AsyncMock(side_effect=search),
|
||||
) as mocked_search, patch(
|
||||
"inse.dashboard.service.elasticsearch.scan",
|
||||
new=scan,
|
||||
), patch(
|
||||
"inse.dashboard.service.InstitutionsSearchClient.get_institution_aliases_by_oa_institution_id",
|
||||
new=AsyncMock(return_value=["Example University"]),
|
||||
@@ -721,6 +1056,11 @@ async def test_top_authors_can_rank_works_by_last_five_years():
|
||||
"count": 2,
|
||||
}
|
||||
|
||||
assert len(scan_calls) == 1
|
||||
assert scan_calls[0]["query"]["bool"]["must"][1] == {
|
||||
"terms": {"publication_year": list(range(current_year - 4, current_year + 1))}
|
||||
}
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_topic_heatmap_maps_field_year_counts_and_shares():
|
||||
|
||||
@@ -361,6 +361,7 @@ class InstitutionsSearchClient:
|
||||
"government",
|
||||
"facility",
|
||||
"other",
|
||||
"funder",
|
||||
}
|
||||
|
||||
cleaned_source = {}
|
||||
|
||||
@@ -33,6 +33,7 @@ _VALID_INSTITUTION_TYPES = {
|
||||
"government",
|
||||
"facility",
|
||||
"other",
|
||||
"funder",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -174,3 +174,34 @@ async def test_list_institutions_accepts_practical_openalex_type_variants():
|
||||
assert result.results[0].counts_by_year[0].cited_by_count is None
|
||||
assert result.group_by[0].key == "true"
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_list_institutions_accepts_funder_institution_type():
|
||||
def handler(_: httpx.Request) -> httpx.Response:
|
||||
return httpx.Response(
|
||||
200,
|
||||
json={
|
||||
"meta": {"count": 1, "page": 1, "per_page": 25},
|
||||
"results": [
|
||||
{
|
||||
"id": "https://openalex.org/I4210119759",
|
||||
"display_name": "Essen University Hospital",
|
||||
"country_code": "DE",
|
||||
"type": "funder",
|
||||
}
|
||||
],
|
||||
},
|
||||
)
|
||||
|
||||
client = OpenAlexInstitutionsClient(
|
||||
api_key="test-key",
|
||||
transport=httpx.MockTransport(handler),
|
||||
)
|
||||
|
||||
result = await logic.list_institutions(client=client)
|
||||
|
||||
assert result.results[0].id == "https://openalex.org/I4210119759"
|
||||
assert result.results[0].display_name == "Essen University Hospital"
|
||||
assert result.results[0].type == "funder"
|
||||
|
||||
|
||||
|
||||
@@ -142,20 +142,55 @@ async def autocomplete_institutions(
|
||||
if not query:
|
||||
return InstitutionPageV2(elements=[], total=0, page=0, size=0)
|
||||
|
||||
stripped = query.strip()
|
||||
fields = [("display_name", 1.0), ("display_name_alternatives", 0.8)]
|
||||
should_clauses = []
|
||||
for field, weight in fields:
|
||||
should_clauses.extend([
|
||||
{
|
||||
"prefix": {
|
||||
f"{field}.keyword": {
|
||||
"value": stripped,
|
||||
"case_insensitive": True,
|
||||
"boost": 10.0 * weight,
|
||||
}
|
||||
}
|
||||
},
|
||||
{"match_phrase_prefix": {field: {"query": stripped, "boost": 5.0 * weight, "slop": 3}}},
|
||||
{"match_bool_prefix": {field: {"query": stripped, "boost": 2.0 * weight}}},
|
||||
{
|
||||
"constant_score": {
|
||||
"filter": {
|
||||
"wildcard": {
|
||||
f"{field}.keyword": {
|
||||
"value": f"*{stripped}*",
|
||||
"case_insensitive": True,
|
||||
}
|
||||
}
|
||||
},
|
||||
"boost": 1.0 * weight,
|
||||
}
|
||||
},
|
||||
])
|
||||
|
||||
return await search_institutions(
|
||||
page=page,
|
||||
size=size,
|
||||
query={
|
||||
"bool": {
|
||||
"should": [
|
||||
{"match_phrase_prefix": {"display_name": query}},
|
||||
{"match_phrase_prefix": {"display_name_alternatives": query}},
|
||||
]
|
||||
"function_score": {
|
||||
"query": {"bool": {"should": should_clauses, "minimum_should_match": 1}},
|
||||
"field_value_factor": {
|
||||
"field": "works_count",
|
||||
"modifier": "log1p",
|
||||
"factor": 0.05,
|
||||
"missing": 1.0,
|
||||
},
|
||||
"boost_mode": "multiply",
|
||||
}
|
||||
},
|
||||
source=source,
|
||||
)
|
||||
|
||||
|
||||
|
||||
async def autocomplete_institutions_for_selector(
|
||||
query: str, page: int = 0, size: int = 10
|
||||
|
||||
@@ -170,25 +170,6 @@ class DfgProjectPublicationSummary(BaseModel):
|
||||
)
|
||||
|
||||
|
||||
class DfgProjectSubjectArea(BaseModel):
|
||||
"""A single subject-area classification entry (DFG 'Fachsystematik')."""
|
||||
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
fach: str | None = None
|
||||
fachgebiet: str | None = None
|
||||
fachkollegium: str | None = None
|
||||
wissenschaftsbereich: str | None = None
|
||||
|
||||
@classmethod
|
||||
def from_inner(cls, f: DFGProjectFachgebieteInner) -> "DfgProjectSubjectArea":
|
||||
return cls(
|
||||
fach=f.fach,
|
||||
fachgebiet=f.fachgebiet,
|
||||
fachkollegium=f.fachkollegium,
|
||||
wissenschaftsbereich=f.wissenschaftsbereich,
|
||||
)
|
||||
|
||||
|
||||
class DfgProjectDetails(BaseModel):
|
||||
"""
|
||||
@@ -253,7 +234,7 @@ class DfgProjectDetails(BaseModel):
|
||||
|
||||
subject_area_de: str | None = Field(default=None, description="Subject area, summary text (German)")
|
||||
subject_area_en: str | None = Field(default=None, description="Subject area, summary text (English)")
|
||||
subject_classifications: list[DfgProjectSubjectArea] = Field(
|
||||
subject_classifications: list[DFGProjectFachgebieteInner] = Field(
|
||||
default_factory=list,
|
||||
description="Detailed DFG subject-area classification entries (Fachsystematik)",
|
||||
)
|
||||
@@ -319,7 +300,7 @@ class DfgProjectDetails(BaseModel):
|
||||
DfgProjectPublicationSummary.from_inner(p) for p in (project.publications or [])
|
||||
]
|
||||
subject_classifications = [
|
||||
DfgProjectSubjectArea.from_inner(f) for f in (project.fachgebiete or [])
|
||||
DFGProjectFachgebieteInner.from_dict(f) for f in (project.subject_classifications or [])
|
||||
]
|
||||
|
||||
# De-duplicated flat views, order-preserving
|
||||
@@ -383,8 +364,6 @@ class DfgProjectDetails(BaseModel):
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: dict) -> "DfgProjectDetails":
|
||||
"""Convenience constructor from a raw dict (e.g. a JSON API response body)."""
|
||||
obj = cls._sanitize_raw_project_dict(obj)
|
||||
return cls.from_dfg_project(DFGProject.from_dict(obj))
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -37,7 +37,7 @@ class Institution(BaseModel):
|
||||
ror: StrictStr | None = Field(default=None, description="The ROR ID for this institution. This is the Canonical External ID for institutions.")
|
||||
display_name: StrictStr | None = Field(default=None, description="The primary name of the institution.")
|
||||
country_code: StrictStr | None = Field(default=None, description="ISO two-letter country code where this institution is located.")
|
||||
type: StrictStr | None = Field(default=None, description="The institution's primary type (ROR vocabulary): `Education`, `Healthcare`, `Company`, `Archive`, `Nonprofit`, `Government`, `Facility`, `Other`.")
|
||||
type: StrictStr | None = Field(default=None, description="The institution's primary type (ROR vocabulary): `Education`, `Healthcare`, `Company`, `Archive`, `Nonprofit`, `Government`, `Facility`, `Other`, `Funder`.")
|
||||
homepage_url: StrictStr | None = Field(default=None, description="URL for the institution's primary homepage.")
|
||||
image_url: StrictStr | None = Field(default=None, description="URL for an image representing this institution (usually from Wikimedia).")
|
||||
image_thumbnail_url: StrictStr | None = Field(default=None, description="Smaller version of `image_url`.")
|
||||
@@ -61,8 +61,9 @@ class Institution(BaseModel):
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in set(['education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other']):
|
||||
raise ValueError("must be one of enum values ('education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other')")
|
||||
valid_types = {'education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other', 'funder'}
|
||||
if value not in valid_types:
|
||||
return 'other'
|
||||
return value
|
||||
|
||||
model_config = ConfigDict(
|
||||
|
||||
@@ -49,7 +49,6 @@ class DFGProject(BaseModel):
|
||||
equipment_group: StrictStr | None = None
|
||||
equipment_name: StrictStr | None = None
|
||||
external_link: StrictStr | None = None
|
||||
fachgebiete: list[DFGProjectFachgebieteInner] | None = None
|
||||
fetched_at: datetime | None = None
|
||||
final_report_abstract_de: StrictStr | None = None
|
||||
final_report_abstract_en: StrictStr | None = None
|
||||
@@ -81,7 +80,7 @@ class DFGProject(BaseModel):
|
||||
publications: list[DFGProjectPublicationsInner] | None = None
|
||||
subject_area_de: StrictStr | None = None
|
||||
subject_area_en: StrictStr | None = None
|
||||
subject_classifications: DFGProjectFachgebieteInner | None = None
|
||||
subject_classifications: list[DFGProjectFachgebieteInner] | None = None
|
||||
subproject_order: list[StrictStr] | None = None
|
||||
subprojects: list[DFGProjectSubprojectsInner] | None = None
|
||||
template_type: StrictStr | None = None
|
||||
@@ -90,7 +89,7 @@ class DFGProject(BaseModel):
|
||||
website_html_de: StrictStr | None = None
|
||||
website_html_en: StrictStr | None = None
|
||||
topics: list[Topic] | None = None
|
||||
__properties: ClassVar[list[str]] = ["abstract_de", "abstract_en", "equipment_group", "equipment_name", "external_link", "fachgebiete", "fetched_at", "final_report_abstract_de", "final_report_abstract_en", "funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "id", "institution_roles_order", "institutions", "international_relation_de", "international_relation_en", "is_transfer_project", "link", "page_url", "parent_project_id", "parent_title_de", "parent_title_en", "person_roles_order", "persons", "project", "project_id", "project_identifier_de", "project_identifier_en", "publications", "subject_area_de", "subject_area_en", "subject_classifications", "subproject_order", "subprojects", "template_type", "title_de", "title_en", "website_html_de", "website_html_en"]
|
||||
__properties: ClassVar[list[str]] = ["abstract_de", "abstract_en", "equipment_group", "equipment_name", "external_link","fetched_at", "final_report_abstract_de", "final_report_abstract_en", "funding_end", "funding_period_de", "funding_period_en", "funding_start", "funding_type_de", "funding_type_en", "funding_type_key", "funding_type_sort", "id", "institution_roles_order", "institutions", "international_relation_de", "international_relation_en", "is_transfer_project", "link", "page_url", "parent_project_id", "parent_title_de", "parent_title_en", "person_roles_order", "persons", "project", "project_id", "project_identifier_de", "project_identifier_en", "publications", "subject_area_de", "subject_area_en", "subject_classifications", "subproject_order", "subprojects", "template_type", "title_de", "title_en", "website_html_de", "website_html_en"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
@@ -131,13 +130,6 @@ class DFGProject(BaseModel):
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in fachgebiete (list)
|
||||
_items = []
|
||||
if self.fachgebiete:
|
||||
for _item_fachgebiete in self.fachgebiete:
|
||||
if _item_fachgebiete:
|
||||
_items.append(_item_fachgebiete.to_dict())
|
||||
_dict['fachgebiete'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in institutions (list)
|
||||
_items = []
|
||||
if self.institutions:
|
||||
@@ -164,7 +156,7 @@ class DFGProject(BaseModel):
|
||||
_dict['publications'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of subject_classifications
|
||||
if self.subject_classifications:
|
||||
_dict['subject_classifications'] = self.subject_classifications.to_dict()
|
||||
_dict['subject_classifications'] = [f.to_dict() for f in self.subject_classifications]
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in subprojects (list)
|
||||
_items = []
|
||||
if self.subprojects:
|
||||
@@ -191,14 +183,12 @@ class DFGProject(BaseModel):
|
||||
key=lambda t: t.get("rank") if t.get("rank") is not None else float("inf"),
|
||||
)
|
||||
topics = [cls._topic_from_match(t) for t in sorted_topics_raw]
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"abstract_de": obj.get("abstract_de"),
|
||||
"abstract_en": obj.get("abstract_en"),
|
||||
"equipment_group": obj.get("equipment_group"),
|
||||
"equipment_name": obj.get("equipment_name"),
|
||||
"external_link": obj.get("external_link"),
|
||||
"fachgebiete": [DFGProjectFachgebieteInner.from_dict(_item) for _item in obj["fachgebiete"]] if obj.get("fachgebiete") is not None else None,
|
||||
"fetched_at": obj.get("fetched_at"),
|
||||
"final_report_abstract_de": obj.get("final_report_abstract_de"),
|
||||
"final_report_abstract_en": obj.get("final_report_abstract_en"),
|
||||
@@ -230,7 +220,7 @@ class DFGProject(BaseModel):
|
||||
"publications": [DFGProjectPublicationsInner.from_dict(_item) for _item in obj["publications"]] if obj.get("publications") is not None else None,
|
||||
"subject_area_de": obj.get("subject_area_de"),
|
||||
"subject_area_en": obj.get("subject_area_en"),
|
||||
"subject_classifications": DFGProjectFachgebieteInner.from_dict(obj["subject_classifications"]) if obj.get("subject_classifications") is not None else None,
|
||||
"subject_classifications": [DFGProjectFachgebieteInner.from_dict(f) for f in (obj.get("subject_classifications") or [])],
|
||||
"subproject_order": obj.get("subproject_order"),
|
||||
"subprojects": [DFGProjectSubprojectsInner.from_dict(_item) for _item in obj["subprojects"]] if obj.get("subprojects") is not None else None,
|
||||
"template_type": obj.get("template_type"),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Find patents for extracted OpenAlex keywords via patents_openalex_keywords index."""
|
||||
"""Find patents for extracted OpenAlex keywords via IPC/CPC reverse lookup."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
@@ -31,7 +31,6 @@ from inse.patents.ipc_lookup import (
|
||||
)
|
||||
from inse.patents.ipc_search_client import IpcSearchClient
|
||||
from inse.patents.keywords.model import (
|
||||
KeywordEvidence,
|
||||
KeywordPatentMappingStatus,
|
||||
KeywordPatentMatch,
|
||||
KeywordPatentSearchDiagnostics,
|
||||
@@ -76,13 +75,7 @@ _MIN_LEADER_RELATIVE_MASS = 0.20
|
||||
_MIN_LEADER_MASS_RATIO = 1.5
|
||||
_TARGET_CUMULATIVE_CLUSTER_MASS = 0.75
|
||||
_MIN_PATENT_MATCH_SCORE = 0.50
|
||||
_MIN_TEXT_PATENT_MATCH_SCORE = 0.30
|
||||
_DEFAULT_SCORE_WEIGHTS = {"ipc": 0.60, "topic": 0.25, "text": 0.15}
|
||||
# When IPC mapping is abstained, score only topic + text evidence.
|
||||
_TEXT_SCORE_WEIGHTS = {"ipc": 0.0, "topic": 0.45, "text": 0.55}
|
||||
# Also try title/abstract search when IPC mapping produced terms but scoring
|
||||
# returned no patents (empty retrieval or over-filtering).
|
||||
_TEXT_SEARCH_AFTER_EMPTY_IPC = True
|
||||
_TOPIC_SCORE_TOPIC_ID = 1.0
|
||||
_TOPIC_SCORE_SUBFIELD = 0.7
|
||||
_TOPIC_SCORE_COMPATIBLE_FIELD = 0.3
|
||||
@@ -618,12 +611,6 @@ class TopicEvidence:
|
||||
score: float
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class TextGateDecision:
|
||||
accepted: bool
|
||||
reason: str
|
||||
|
||||
|
||||
def _compute_topic_evidence(
|
||||
patent_topics: list[MappedOpenAlexTopic],
|
||||
keyword_topic_ids: frozenset[str],
|
||||
@@ -702,16 +689,6 @@ def _tokenize_words(text: str) -> list[str]:
|
||||
return re.findall(r"[a-z0-9äöüß]+", (text or "").casefold())
|
||||
|
||||
|
||||
def _contains_token_sequence(haystack: list[str], needle: list[str]) -> bool:
|
||||
if not needle or len(needle) > len(haystack):
|
||||
return False
|
||||
width = len(needle)
|
||||
for index in range(len(haystack) - width + 1):
|
||||
if haystack[index : index + width] == needle:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def _token_set(tokens: list[str]) -> set[str]:
|
||||
return set(tokens)
|
||||
|
||||
@@ -735,23 +712,6 @@ def _text_search_terms(items: list[KeywordPatentSearchItem]) -> list[str]:
|
||||
return terms
|
||||
|
||||
|
||||
def _text_search_phrases(items: list[KeywordPatentSearchItem]) -> list[str]:
|
||||
"""Full phrases for ES title/abstract retrieval (text path)."""
|
||||
phrases: list[str] = []
|
||||
seen: set[str] = set()
|
||||
for item in items:
|
||||
for value in (item.keyword, item.topic_display_name):
|
||||
cleaned = " ".join((value or "").strip().split())
|
||||
if len(cleaned) < 3:
|
||||
continue
|
||||
key = cleaned.casefold()
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
phrases.append(cleaned)
|
||||
return phrases
|
||||
|
||||
|
||||
def _text_overlap_score(
|
||||
patent: model.PatentEntry,
|
||||
search_terms: list[str],
|
||||
@@ -772,173 +732,6 @@ def _text_overlap_score(
|
||||
return min(hits / 3, 1.0)
|
||||
|
||||
|
||||
def _text_match_kind(
|
||||
*,
|
||||
phrase_in_title: bool,
|
||||
phrase_in_abstract: bool,
|
||||
full_token_match: bool,
|
||||
partial_token_match: bool,
|
||||
) -> str:
|
||||
if phrase_in_title:
|
||||
return "phrase_title"
|
||||
if phrase_in_abstract:
|
||||
return "phrase_abstract"
|
||||
if full_token_match:
|
||||
return "full_token"
|
||||
if partial_token_match:
|
||||
return "partial_token"
|
||||
return "none"
|
||||
|
||||
|
||||
def _collect_keyword_text_evidence(
|
||||
patent: model.PatentEntry,
|
||||
phrases: list[str],
|
||||
search_terms: list[str],
|
||||
) -> KeywordEvidence:
|
||||
"""Record phrase / full-token / partial-token evidence separately."""
|
||||
title_tokens = _tokenize_words(patent.title or "")
|
||||
abstract_tokens = _tokenize_words(patent.abstract or "")
|
||||
combined_tokens = _token_set(title_tokens + abstract_tokens)
|
||||
|
||||
phrase_in_title = False
|
||||
phrase_in_abstract = False
|
||||
full_token_match = False
|
||||
partial_token_match = False
|
||||
matched_phrases: list[str] = []
|
||||
|
||||
for phrase in phrases:
|
||||
phrase_tokens = _tokenize_words(phrase)
|
||||
if not phrase_tokens:
|
||||
continue
|
||||
if _contains_token_sequence(title_tokens, phrase_tokens):
|
||||
phrase_in_title = True
|
||||
matched_phrases.append(phrase)
|
||||
elif _contains_token_sequence(abstract_tokens, phrase_tokens):
|
||||
phrase_in_abstract = True
|
||||
matched_phrases.append(phrase)
|
||||
|
||||
present = [token for token in phrase_tokens if token in combined_tokens]
|
||||
if present and len(present) == len(phrase_tokens):
|
||||
full_token_match = True
|
||||
elif present:
|
||||
partial_token_match = True
|
||||
|
||||
matched_words = [term for term in search_terms if term in combined_tokens]
|
||||
if matched_words and not full_token_match and not partial_token_match:
|
||||
# Lone search-term hits without a covering phrase count as partial.
|
||||
partial_token_match = True
|
||||
|
||||
word_match_score = (
|
||||
min(len(matched_words) / 3, 1.0) if search_terms and matched_words else 0.0
|
||||
)
|
||||
kind = _text_match_kind(
|
||||
phrase_in_title=phrase_in_title,
|
||||
phrase_in_abstract=phrase_in_abstract,
|
||||
full_token_match=full_token_match,
|
||||
partial_token_match=partial_token_match,
|
||||
)
|
||||
|
||||
return KeywordEvidence(
|
||||
phrase_in_title=phrase_in_title,
|
||||
phrase_in_abstract=phrase_in_abstract,
|
||||
full_token_match=full_token_match,
|
||||
partial_token_match=partial_token_match,
|
||||
word_match_score=round(word_match_score, 4),
|
||||
matched_phrases=list(dict.fromkeys(matched_phrases)),
|
||||
matched_words=matched_words,
|
||||
text_match_kind=kind,
|
||||
)
|
||||
|
||||
|
||||
def _keyword_text_score(evidence: KeywordEvidence) -> float:
|
||||
if evidence.phrase_in_title:
|
||||
return 1.0
|
||||
if evidence.phrase_in_abstract:
|
||||
return 0.85
|
||||
if evidence.full_token_match:
|
||||
return 0.55
|
||||
if evidence.partial_token_match:
|
||||
return 0.25
|
||||
return 0.0
|
||||
|
||||
|
||||
def _exact_topic_or_subfield_match(
|
||||
patent_topics: list[MappedOpenAlexTopic],
|
||||
keyword_topic_ids: frozenset[str],
|
||||
keyword_subfield_names: frozenset[str],
|
||||
) -> bool:
|
||||
evidence = _compute_topic_evidence(
|
||||
patent_topics,
|
||||
keyword_topic_ids,
|
||||
keyword_subfield_names,
|
||||
frozenset(),
|
||||
)
|
||||
return evidence.match_kind in {"topic_id", "subfield"}
|
||||
|
||||
|
||||
def _keyword_text_passes_relevance_gate(
|
||||
evidence: KeywordEvidence,
|
||||
*,
|
||||
topic_evidence: TopicEvidence,
|
||||
) -> TextGateDecision:
|
||||
"""Keyword text acceptance policy (no domain hardcoding).
|
||||
|
||||
Accept:
|
||||
- phrase in title (strong)
|
||||
- phrase in abstract (medium)
|
||||
- exact topic/subfield together with full token text evidence
|
||||
Reject:
|
||||
- partial/general words alone
|
||||
- compatible field alone
|
||||
- exact topic/subfield without text evidence
|
||||
"""
|
||||
exact = topic_evidence.match_kind in {"topic_id", "subfield"}
|
||||
|
||||
if evidence.phrase_in_title:
|
||||
return TextGateDecision(True, "phrase_in_title")
|
||||
if evidence.phrase_in_abstract:
|
||||
return TextGateDecision(True, "phrase_in_abstract")
|
||||
if exact and evidence.full_token_match:
|
||||
return TextGateDecision(
|
||||
True,
|
||||
f"{topic_evidence.match_kind}_with_full_token_match",
|
||||
)
|
||||
if exact and evidence.partial_token_match:
|
||||
return TextGateDecision(False, "exact_topic_with_partial_tokens_only")
|
||||
if exact:
|
||||
return TextGateDecision(False, "exact_topic_without_text")
|
||||
if topic_evidence.match_kind == "compatible_field":
|
||||
return TextGateDecision(False, "compatible_field_only")
|
||||
if evidence.partial_token_match or evidence.matched_words:
|
||||
return TextGateDecision(False, "partial_or_loose_words_only")
|
||||
return TextGateDecision(False, "insufficient_evidence")
|
||||
|
||||
|
||||
def _matched_keyword_labels_from_evidence(
|
||||
items: list[KeywordPatentSearchItem],
|
||||
evidence: KeywordEvidence,
|
||||
) -> list[str]:
|
||||
matched: list[str] = []
|
||||
seen: set[str] = set()
|
||||
phrase_keys = {phrase.casefold() for phrase in evidence.matched_phrases}
|
||||
word_keys = set(evidence.matched_words)
|
||||
|
||||
for item in items:
|
||||
for value in (item.keyword, item.topic_display_name):
|
||||
label = (value or "").strip()
|
||||
if not label:
|
||||
continue
|
||||
key = label.casefold()
|
||||
if key in seen:
|
||||
continue
|
||||
label_tokens = _tokenize_words(label)
|
||||
if key in phrase_keys or any(token in word_keys for token in label_tokens):
|
||||
seen.add(key)
|
||||
matched.append(label)
|
||||
break
|
||||
return matched
|
||||
|
||||
|
||||
def _patent_passes_relevance_gate(
|
||||
patent_topics: list[MappedOpenAlexTopic],
|
||||
*,
|
||||
@@ -1261,210 +1054,6 @@ async def _score_patents_with_ipc(
|
||||
}
|
||||
|
||||
|
||||
async def _score_patents_text_search(
|
||||
*,
|
||||
raw_patents: list[model.PatentEntry],
|
||||
search_keywords: list[KeywordPatentSearchItem],
|
||||
phrases: list[str],
|
||||
text_search_terms: list[str],
|
||||
keyword_topic_ids: frozenset[str],
|
||||
keyword_subfield_names: frozenset[str],
|
||||
keyword_soft_field_names: frozenset[str],
|
||||
resolver: PatentOpenAlexMappingResolver,
|
||||
) -> tuple[list[KeywordPatentMatch], dict[str, int]]:
|
||||
"""Score patents without IPC using graded topic + structured text evidence."""
|
||||
patent_topics_by_key = await resolver.resolve_topics_for_patents(raw_patents)
|
||||
scored: list[KeywordPatentMatch] = []
|
||||
filtered_by_relevance_gate = 0
|
||||
filtered_by_min_score = 0
|
||||
passed_relevance_gate = 0
|
||||
|
||||
for patent in raw_patents:
|
||||
patent_topics = patent_topics_by_key.get(patent_map_key(patent), [])
|
||||
evidence = _collect_keyword_text_evidence(patent, phrases, text_search_terms)
|
||||
topic_evidence = _compute_topic_evidence(
|
||||
patent_topics,
|
||||
keyword_topic_ids,
|
||||
keyword_subfield_names,
|
||||
keyword_soft_field_names,
|
||||
)
|
||||
decision = _keyword_text_passes_relevance_gate(
|
||||
evidence,
|
||||
topic_evidence=topic_evidence,
|
||||
)
|
||||
if not decision.accepted:
|
||||
filtered_by_relevance_gate += 1
|
||||
logger.info(
|
||||
"Text reject: id=%s title=%s topic_kind=%s topic_score=%.2f "
|
||||
"text_kind=%s phrase_title=%s phrase_abstract=%s "
|
||||
"full_token=%s partial_token=%s reason=%s",
|
||||
patent.patent_id,
|
||||
patent.title,
|
||||
topic_evidence.match_kind,
|
||||
topic_evidence.score,
|
||||
evidence.text_match_kind,
|
||||
evidence.phrase_in_title,
|
||||
evidence.phrase_in_abstract,
|
||||
evidence.full_token_match,
|
||||
evidence.partial_token_match,
|
||||
decision.reason,
|
||||
)
|
||||
continue
|
||||
|
||||
passed_relevance_gate += 1
|
||||
text_score = _keyword_text_score(evidence)
|
||||
# Field-only remains a weak ranking signal when already accepted via phrase.
|
||||
score = _compute_final_score(
|
||||
0.0,
|
||||
topic_evidence.score,
|
||||
text_score,
|
||||
weights=_TEXT_SCORE_WEIGHTS,
|
||||
)
|
||||
if score < _MIN_TEXT_PATENT_MATCH_SCORE:
|
||||
filtered_by_min_score += 1
|
||||
logger.info(
|
||||
"Text reject: id=%s reason=below_min_score score=%.4f",
|
||||
patent.patent_id,
|
||||
score,
|
||||
)
|
||||
continue
|
||||
|
||||
logger.info(
|
||||
"Text accept: id=%s title=%s topic_kind=%s topic_score=%.2f "
|
||||
"text_kind=%s text_score=%.2f final_score=%.4f reason=%s",
|
||||
patent.patent_id,
|
||||
patent.title,
|
||||
topic_evidence.match_kind,
|
||||
topic_evidence.score,
|
||||
evidence.text_match_kind,
|
||||
text_score,
|
||||
score,
|
||||
decision.reason,
|
||||
)
|
||||
scored.append(
|
||||
KeywordPatentMatch(
|
||||
patent=patent,
|
||||
match_score=score,
|
||||
ipc_score=0.0,
|
||||
topic_score=topic_evidence.score,
|
||||
text_score=text_score,
|
||||
matched_keywords=_matched_keyword_labels_from_evidence(
|
||||
search_keywords,
|
||||
evidence,
|
||||
),
|
||||
matched_ipc_symbols=[],
|
||||
text_retrieval=True,
|
||||
keyword_evidence=evidence,
|
||||
topic_match_kind=topic_evidence.match_kind,
|
||||
)
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"Keyword patent text search: filtered_by_relevance_gate=%d "
|
||||
"filtered_by_min_score=%d passed_relevance_gate=%d scored=%d",
|
||||
filtered_by_relevance_gate,
|
||||
filtered_by_min_score,
|
||||
passed_relevance_gate,
|
||||
len(scored),
|
||||
)
|
||||
return scored, {
|
||||
"filtered_by_relevance_gate": filtered_by_relevance_gate,
|
||||
"filtered_by_min_score": filtered_by_min_score,
|
||||
"passed_relevance_gate": passed_relevance_gate,
|
||||
}
|
||||
|
||||
|
||||
async def _search_patents_text_search(
|
||||
*,
|
||||
client: BasePatentSearchClient,
|
||||
queries: IpcPatentSearchQueries,
|
||||
ipc_search: IpcSearchClient,
|
||||
resolver: PatentOpenAlexMappingResolver,
|
||||
search_keywords: list[KeywordPatentSearchItem],
|
||||
keyword_topic_ids: frozenset[str],
|
||||
keyword_subfield_names: frozenset[str],
|
||||
keyword_soft_field_names: frozenset[str],
|
||||
mapping_status: KeywordPatentMappingStatus,
|
||||
ipc_cluster_selections: list[dict] | None = None,
|
||||
) -> PatentsByKeywordsResponse:
|
||||
cluster_dicts = list(ipc_cluster_selections or [])
|
||||
phrases = _text_search_phrases(search_keywords)
|
||||
text_search_terms = _text_search_terms(search_keywords)
|
||||
if not phrases:
|
||||
logger.info(
|
||||
"Keyword patent text search: no phrases for keywords %s",
|
||||
[item.keyword for item in search_keywords],
|
||||
)
|
||||
return PatentsByKeywordsResponse(
|
||||
patent_count=0,
|
||||
patents=[],
|
||||
mapping_status="no_patents_found",
|
||||
diagnostics=_empty_diagnostics(
|
||||
search_path="text",
|
||||
ipc_cluster_selections=cluster_dicts,
|
||||
),
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"Keyword patent text search: mapping_status=%s phrases=%s",
|
||||
mapping_status,
|
||||
phrases,
|
||||
)
|
||||
raw_patents = await _fetch_patents_for_queries(
|
||||
client,
|
||||
queries.epo_query_by_text_phrases(phrases, size=_MAX_PATENTS),
|
||||
queries.uspto_query_by_text_phrases(phrases, size=_MAX_PATENTS),
|
||||
)
|
||||
if raw_patents is None:
|
||||
return PatentsByKeywordsResponse(
|
||||
patent_count=0,
|
||||
patents=[],
|
||||
mapping_status="search_error",
|
||||
diagnostics=_empty_diagnostics(
|
||||
search_path="text",
|
||||
ipc_cluster_selections=cluster_dicts,
|
||||
),
|
||||
)
|
||||
|
||||
logger.info("Keyword patent text search: raw_patents=%d", len(raw_patents))
|
||||
scored, filter_counts = await _score_patents_text_search(
|
||||
raw_patents=raw_patents,
|
||||
search_keywords=search_keywords,
|
||||
phrases=phrases,
|
||||
text_search_terms=text_search_terms,
|
||||
keyword_topic_ids=keyword_topic_ids,
|
||||
keyword_subfield_names=keyword_subfield_names,
|
||||
keyword_soft_field_names=keyword_soft_field_names,
|
||||
resolver=resolver,
|
||||
)
|
||||
scored, diagnostics = _finalize_scored_patents(
|
||||
scored,
|
||||
raw_count=len(raw_patents),
|
||||
filtered_by_ipc=0,
|
||||
filtered_by_relevance_gate=filter_counts["filtered_by_relevance_gate"],
|
||||
filtered_by_min_score=filter_counts["filtered_by_min_score"],
|
||||
passed_relevance_gate=filter_counts["passed_relevance_gate"],
|
||||
search_path="text",
|
||||
ipc_cluster_selections=cluster_dicts,
|
||||
)
|
||||
await enrich_patents_classifications([item.patent for item in scored], ipc_search)
|
||||
|
||||
if not scored:
|
||||
return PatentsByKeywordsResponse(
|
||||
patent_count=0,
|
||||
patents=[],
|
||||
mapping_status="no_patents_found",
|
||||
diagnostics=diagnostics,
|
||||
)
|
||||
|
||||
return PatentsByKeywordsResponse(
|
||||
patent_count=len(scored),
|
||||
patents=scored,
|
||||
mapping_status=mapping_status,
|
||||
diagnostics=diagnostics,
|
||||
)
|
||||
|
||||
|
||||
async def get_patents_by_keywords(
|
||||
request: PatentsByKeywordsRequest,
|
||||
*,
|
||||
@@ -1528,21 +1117,18 @@ async def get_patents_by_keywords(
|
||||
)
|
||||
logger.info(
|
||||
"Keyword patent search: no IPC search terms for keywords %s "
|
||||
"(mapping_status=%s) — trying keyword text search",
|
||||
"(mapping_status=%s)",
|
||||
[item.keyword for item in search_keywords],
|
||||
mapping_status,
|
||||
)
|
||||
return await _search_patents_text_search(
|
||||
client=client,
|
||||
queries=queries,
|
||||
ipc_search=ipc_search,
|
||||
resolver=resolver,
|
||||
search_keywords=search_keywords,
|
||||
keyword_topic_ids=keyword_topic_ids,
|
||||
keyword_subfield_names=keyword_subfield_names,
|
||||
keyword_soft_field_names=keyword_soft_field_names,
|
||||
return PatentsByKeywordsResponse(
|
||||
patent_count=0,
|
||||
patents=[],
|
||||
mapping_status=mapping_status,
|
||||
ipc_cluster_selections=cluster_dicts,
|
||||
diagnostics=_empty_diagnostics(
|
||||
search_path="none",
|
||||
ipc_cluster_selections=cluster_dicts,
|
||||
),
|
||||
)
|
||||
|
||||
text_search_terms = _text_search_terms(search_keywords)
|
||||
@@ -1594,31 +1180,11 @@ async def get_patents_by_keywords(
|
||||
diagnostics=diagnostics,
|
||||
)
|
||||
|
||||
if not _TEXT_SEARCH_AFTER_EMPTY_IPC:
|
||||
return PatentsByKeywordsResponse(
|
||||
patent_count=0,
|
||||
patents=[],
|
||||
mapping_status="no_patents_found",
|
||||
diagnostics=diagnostics,
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"Keyword patent search: IPC path yielded no scored patents — "
|
||||
"trying keyword text search (policy=_TEXT_SEARCH_AFTER_EMPTY_IPC)"
|
||||
)
|
||||
return await _search_patents_text_search(
|
||||
client=client,
|
||||
queries=queries,
|
||||
ipc_search=ipc_search,
|
||||
resolver=resolver,
|
||||
search_keywords=search_keywords,
|
||||
keyword_topic_ids=keyword_topic_ids,
|
||||
keyword_subfield_names=keyword_subfield_names,
|
||||
keyword_soft_field_names=keyword_soft_field_names,
|
||||
# IPC was selected but produced no usable hits; UI treats this like
|
||||
# uncertain IPC evidence and labels patents via text_retrieval.
|
||||
mapping_status="uncertain",
|
||||
ipc_cluster_selections=cluster_dicts,
|
||||
return PatentsByKeywordsResponse(
|
||||
patent_count=0,
|
||||
patents=[],
|
||||
mapping_status="no_patents_found",
|
||||
diagnostics=diagnostics,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -46,19 +46,12 @@ _USPTO_SOURCE_FIELDS = [
|
||||
]
|
||||
|
||||
_MIN_MATCH_TERM_LEN = 4
|
||||
_MIN_TEXT_PHRASE_LEN = 3
|
||||
|
||||
# Prefer concrete group/subgroup hits over broad subclass prefixes.
|
||||
_BOOST_SUBGROUP = 4.0
|
||||
_BOOST_MAIN_GROUP = 2.5
|
||||
_BOOST_SUBCLASS = 1.0
|
||||
|
||||
# Text search: prefer exact phrases in title over abstract / loose match.
|
||||
_BOOST_TEXT_PHRASE_TITLE = 5.0
|
||||
_BOOST_TEXT_PHRASE_ABSTRACT = 3.0
|
||||
_BOOST_TEXT_MATCH_TITLE = 1.5
|
||||
_BOOST_TEXT_MATCH_ABSTRACT = 1.0
|
||||
|
||||
|
||||
def _add_term_boost(weights: dict[str, float], term: str, boost: float) -> None:
|
||||
cleaned = term.strip()
|
||||
@@ -157,76 +150,6 @@ def _ipc_match_clauses(field: str, term_boosts: dict[str, float]) -> list[dict[s
|
||||
return clauses
|
||||
|
||||
|
||||
def _normalize_text_phrases(phrases: list[str]) -> list[str]:
|
||||
cleaned: list[str] = []
|
||||
seen: set[str] = set()
|
||||
for phrase in phrases:
|
||||
value = " ".join((phrase or "").strip().split())
|
||||
if len(value) < _MIN_TEXT_PHRASE_LEN:
|
||||
continue
|
||||
key = value.casefold()
|
||||
if key in seen:
|
||||
continue
|
||||
seen.add(key)
|
||||
cleaned.append(value)
|
||||
return cleaned
|
||||
|
||||
|
||||
def _text_match_clauses(
|
||||
phrases: list[str],
|
||||
*,
|
||||
title_fields: tuple[str, ...],
|
||||
abstract_field: str,
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Build title/abstract should-clauses with phrase boosts over loose match."""
|
||||
clauses: list[dict[str, Any]] = []
|
||||
for phrase in _normalize_text_phrases(phrases):
|
||||
for field in title_fields:
|
||||
clauses.append(
|
||||
{
|
||||
"match_phrase": {
|
||||
field: {
|
||||
"query": phrase,
|
||||
"boost": _BOOST_TEXT_PHRASE_TITLE,
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
clauses.append(
|
||||
{
|
||||
"match": {
|
||||
field: {
|
||||
"query": phrase,
|
||||
"operator": "and",
|
||||
"boost": _BOOST_TEXT_MATCH_TITLE,
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
clauses.append(
|
||||
{
|
||||
"match_phrase": {
|
||||
abstract_field: {
|
||||
"query": phrase,
|
||||
"boost": _BOOST_TEXT_PHRASE_ABSTRACT,
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
clauses.append(
|
||||
{
|
||||
"match": {
|
||||
abstract_field: {
|
||||
"query": phrase,
|
||||
"operator": "and",
|
||||
"boost": _BOOST_TEXT_MATCH_ABSTRACT,
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
return clauses
|
||||
|
||||
|
||||
class IpcPatentSearchQueries:
|
||||
def epo_query_by_ipc_terms(
|
||||
self,
|
||||
@@ -299,55 +222,3 @@ class IpcPatentSearchQueries:
|
||||
size: int = DEFAULT_SEARCH_SIZE,
|
||||
) -> dict[str, Any]:
|
||||
return self.uspto_query_by_ipc_terms(_merge_term_boosts(symbols), size=size)
|
||||
|
||||
def epo_query_by_text_phrases(
|
||||
self,
|
||||
phrases: list[str],
|
||||
size: int = DEFAULT_SEARCH_SIZE,
|
||||
) -> dict[str, Any]:
|
||||
should = _text_match_clauses(
|
||||
phrases,
|
||||
title_fields=("title_en", "title_de"),
|
||||
abstract_field="abstract",
|
||||
)
|
||||
query: dict[str, Any] = (
|
||||
{"match_none": {}}
|
||||
if not should
|
||||
else {"bool": {"should": should, "minimum_should_match": 1}}
|
||||
)
|
||||
return {
|
||||
"size": size,
|
||||
"track_total_hits": True,
|
||||
"sort": [
|
||||
{"_score": {"order": "desc"}},
|
||||
{"date_publication": {"order": "desc", "missing": "_last"}},
|
||||
],
|
||||
"_source": _PATENT_SOURCE_FIELDS,
|
||||
"query": query,
|
||||
}
|
||||
|
||||
def uspto_query_by_text_phrases(
|
||||
self,
|
||||
phrases: list[str],
|
||||
size: int = DEFAULT_SEARCH_SIZE,
|
||||
) -> dict[str, Any]:
|
||||
should = _text_match_clauses(
|
||||
phrases,
|
||||
title_fields=("title",),
|
||||
abstract_field="abstract",
|
||||
)
|
||||
query: dict[str, Any] = (
|
||||
{"match_none": {}}
|
||||
if not should
|
||||
else {"bool": {"should": should, "minimum_should_match": 1}}
|
||||
)
|
||||
return {
|
||||
"size": size,
|
||||
"track_total_hits": True,
|
||||
"sort": [
|
||||
{"_score": {"order": "desc"}},
|
||||
{"publication_date": {"order": "desc", "missing": "_last"}},
|
||||
],
|
||||
"_source": _USPTO_SOURCE_FIELDS,
|
||||
"query": query,
|
||||
}
|
||||
|
||||
@@ -10,21 +10,17 @@ from inse.patents.authors.ipc_openalex_mapping import MappedOpenAlexTopic
|
||||
from inse.patents.common import model
|
||||
from inse.patents.keywords.logic import (
|
||||
TopicEvidence,
|
||||
_aggregate_subclass_clusters,
|
||||
_collect_keyword_text_evidence,
|
||||
_compute_final_score,
|
||||
_compute_topic_evidence,
|
||||
_exact_topic_or_subfield_match,
|
||||
_filter_keywords_for_patent_search,
|
||||
_ipc_hierarchy_quality,
|
||||
_keyword_is_patent_searchable,
|
||||
_keyword_text_passes_relevance_gate,
|
||||
_keyword_text_score,
|
||||
_patent_passes_relevance_gate,
|
||||
_patent_search_terms,
|
||||
_score_ipc_match,
|
||||
_score_patent,
|
||||
_select_dominant_clusters,
|
||||
_aggregate_subclass_clusters,
|
||||
_term_from_ipc_match,
|
||||
_text_overlap_score,
|
||||
_text_search_terms,
|
||||
@@ -34,10 +30,6 @@ from inse.patents.keywords.logic import (
|
||||
get_patents_by_keywords,
|
||||
select_ipc_matches_by_cluster_mass,
|
||||
)
|
||||
from inse.patents.keywords.model import (
|
||||
KeywordPatentSearchItem,
|
||||
PatentsByKeywordsRequest,
|
||||
)
|
||||
from inse.patents.keywords.reverse_lookup import (
|
||||
IpcCodeMatch,
|
||||
_dedupe_ipc_matches,
|
||||
@@ -45,6 +37,7 @@ from inse.patents.keywords.reverse_lookup import (
|
||||
_weighted_score,
|
||||
clear_reverse_lookup_caches,
|
||||
)
|
||||
from inse.patents.keywords.model import KeywordPatentSearchItem, PatentsByKeywordsRequest
|
||||
from inse.patents.keywords.search_queries import (
|
||||
IpcPatentSearchQueries,
|
||||
_search_terms_for_symbol,
|
||||
@@ -646,132 +639,6 @@ def test_text_overlap_score_uses_word_boundaries_not_substrings() -> None:
|
||||
assert _text_overlap_score(patent, ["chemistry", "organic"]) == 0.0
|
||||
|
||||
|
||||
def test_fallback_rejects_mechanical_patent_for_organic_chemistry() -> None:
|
||||
"""Soft field / loose words must not accept a mechanical separator patent."""
|
||||
patent = model.PatentEntry(
|
||||
patent_id="EP-MECH",
|
||||
source="EPO",
|
||||
title=(
|
||||
"Rotating machine for separating materials in different "
|
||||
"states of aggregation"
|
||||
),
|
||||
abstract="Apparatus for mechanical separation of materials.",
|
||||
ipc=["B01D45/12"],
|
||||
)
|
||||
phrases = ["Organic Chemistry", "organische Chemie"]
|
||||
terms = ["organic", "chemistry", "organische", "chemie"]
|
||||
evidence = _collect_keyword_text_evidence(patent, phrases, terms)
|
||||
|
||||
assert evidence.phrase_in_title is False
|
||||
assert evidence.phrase_in_abstract is False
|
||||
assert evidence.full_token_match is False
|
||||
assert evidence.matched_phrases == []
|
||||
assert evidence.matched_words == []
|
||||
|
||||
field_only = TopicEvidence(match_kind="compatible_field", score=0.3)
|
||||
assert not _keyword_text_passes_relevance_gate(
|
||||
evidence,
|
||||
topic_evidence=field_only,
|
||||
).accepted
|
||||
exact = TopicEvidence(match_kind="topic_id", score=1.0)
|
||||
assert not _keyword_text_passes_relevance_gate(
|
||||
evidence,
|
||||
topic_evidence=exact,
|
||||
).accepted
|
||||
|
||||
|
||||
def test_fallback_accepts_strong_phrase_or_exact_topic_with_full_tokens() -> None:
|
||||
phrase_patent = model.PatentEntry(
|
||||
patent_id="EP-PHRASE",
|
||||
source="EPO",
|
||||
title="Process for organic chemistry synthesis",
|
||||
abstract="Catalytic reactions.",
|
||||
)
|
||||
phrases = ["organic chemistry"]
|
||||
terms = ["organic", "chemistry"]
|
||||
evidence = _collect_keyword_text_evidence(phrase_patent, phrases, terms)
|
||||
assert evidence.phrase_in_title is True
|
||||
assert evidence.text_match_kind == "phrase_title"
|
||||
assert _keyword_text_score(evidence) == 1.0
|
||||
assert _keyword_text_passes_relevance_gate(
|
||||
evidence,
|
||||
topic_evidence=TopicEvidence(match_kind="none", score=0.0),
|
||||
).accepted
|
||||
|
||||
full_token_patent = model.PatentEntry(
|
||||
patent_id="EP-WORDS",
|
||||
source="EPO",
|
||||
title="Catalytic organic synthesis method",
|
||||
abstract="Uses chemistry laboratory techniques.",
|
||||
)
|
||||
full_evidence = _collect_keyword_text_evidence(
|
||||
full_token_patent,
|
||||
phrases,
|
||||
terms,
|
||||
)
|
||||
assert full_evidence.phrase_in_title is False
|
||||
assert full_evidence.phrase_in_abstract is False
|
||||
assert full_evidence.full_token_match is True
|
||||
assert not _keyword_text_passes_relevance_gate(
|
||||
full_evidence,
|
||||
topic_evidence=TopicEvidence(match_kind="none", score=0.0),
|
||||
).accepted
|
||||
assert _keyword_text_passes_relevance_gate(
|
||||
full_evidence,
|
||||
topic_evidence=TopicEvidence(match_kind="topic_id", score=1.0),
|
||||
).accepted
|
||||
|
||||
partial_patent = model.PatentEntry(
|
||||
patent_id="EP-PARTIAL",
|
||||
source="EPO",
|
||||
title="Organic polymer blend",
|
||||
abstract="Industrial materials processing.",
|
||||
)
|
||||
partial_evidence = _collect_keyword_text_evidence(
|
||||
partial_patent,
|
||||
phrases,
|
||||
terms,
|
||||
)
|
||||
assert partial_evidence.partial_token_match is True
|
||||
assert partial_evidence.full_token_match is False
|
||||
decision = _keyword_text_passes_relevance_gate(
|
||||
partial_evidence,
|
||||
topic_evidence=TopicEvidence(match_kind="topic_id", score=1.0),
|
||||
)
|
||||
assert not decision.accepted
|
||||
assert decision.reason == "exact_topic_with_partial_tokens_only"
|
||||
|
||||
assert _exact_topic_or_subfield_match(
|
||||
[
|
||||
MappedOpenAlexTopic(
|
||||
topic_id="https://openalex.org/TORG",
|
||||
topic_display_name="Organic Chemistry",
|
||||
subfield_name="Organic Chemistry",
|
||||
field_name="Chemistry",
|
||||
)
|
||||
],
|
||||
frozenset({"TORG"}),
|
||||
frozenset({"organic chemistry"}),
|
||||
)
|
||||
|
||||
|
||||
def test_token_match_rejects_machine_inside_micromachined() -> None:
|
||||
patent = model.PatentEntry(
|
||||
patent_id="EP-MICRO",
|
||||
source="EPO",
|
||||
title="Micromachined sensor device",
|
||||
abstract="Fabrication of micromachined structures.",
|
||||
)
|
||||
assert _text_overlap_score(patent, ["machine", "learning"]) == 0.0
|
||||
evidence = _collect_keyword_text_evidence(
|
||||
patent,
|
||||
["Machine Learning"],
|
||||
["machine", "learning"],
|
||||
)
|
||||
assert evidence.matched_words == []
|
||||
assert evidence.full_token_match is False
|
||||
|
||||
|
||||
def test_patent_passes_relevance_gate_with_text_but_no_topics() -> None:
|
||||
patent = model.PatentEntry(
|
||||
patent_id="EP1",
|
||||
@@ -914,8 +781,7 @@ def test_get_patents_by_keywords_uses_symbol_queries() -> None:
|
||||
uspto_symbols.assert_called_once()
|
||||
assert epo_symbols.call_args.args[0][0] == "C07C243/08"
|
||||
assert "C07C" in epo_symbols.call_args.args[0]
|
||||
# IPC search returns empty → text fallback also queries EPO/USPTO.
|
||||
assert captured == ["epo", "uspto", "epo", "uspto"]
|
||||
assert captured == ["epo", "uspto"]
|
||||
|
||||
|
||||
def test_text_search_terms_include_topic_metadata() -> None:
|
||||
@@ -993,64 +859,84 @@ def test_epo_and_uspto_queries_boost_specific_symbols_over_subclass() -> None:
|
||||
assert uspto["sort"][0] == {"_score": {"order": "desc"}}
|
||||
|
||||
|
||||
def test_text_queries_prefer_phrase_match_in_title() -> None:
|
||||
queries = IpcPatentSearchQueries()
|
||||
epo = queries.epo_query_by_text_phrases(["organic chemistry"])
|
||||
uspto = queries.uspto_query_by_text_phrases(["organic chemistry"])
|
||||
|
||||
epo_should = epo["query"]["bool"]["should"]
|
||||
uspto_should = uspto["query"]["bool"]["should"]
|
||||
|
||||
def clause_boost(clauses: list[dict], kind: str, field: str) -> float | None:
|
||||
for clause in clauses:
|
||||
payload = clause.get(kind, {}).get(field)
|
||||
if isinstance(payload, dict) and payload.get("query") == "organic chemistry":
|
||||
return float(payload.get("boost", 1.0))
|
||||
return None
|
||||
|
||||
assert clause_boost(epo_should, "match_phrase", "title_en") == 5.0
|
||||
assert clause_boost(epo_should, "match_phrase", "abstract") == 3.0
|
||||
assert clause_boost(epo_should, "match", "title_en") == 1.5
|
||||
assert clause_boost(uspto_should, "match_phrase", "title") == 5.0
|
||||
assert epo["sort"][0] == {"_score": {"order": "desc"}}
|
||||
|
||||
|
||||
def test_uncertain_mapping_uses_text_fallback_not_empty_list() -> None:
|
||||
"""Fragmented IPC abstention must fall back to title/abstract search."""
|
||||
patent = model.PatentEntry(
|
||||
patent_id="EP123",
|
||||
source="EPO",
|
||||
title="Process for organic chemistry synthesis",
|
||||
abstract="A catalytic method in organic chemistry.",
|
||||
publication_date="20240101",
|
||||
ipc=["C07C243/08"],
|
||||
cpc=[],
|
||||
def test_technical_search_failure_returns_search_error_not_no_patents_found() -> None:
|
||||
request = PatentsByKeywordsRequest(
|
||||
keywords=[
|
||||
KeywordPatentSearchItem(
|
||||
keyword="organische Chemie",
|
||||
keyword_level="coarse",
|
||||
topic_id="https://openalex.org/TORG",
|
||||
topic_display_name="Organic Chemistry",
|
||||
field_name="Chemistry",
|
||||
relevance_score=1.0,
|
||||
)
|
||||
]
|
||||
)
|
||||
ipc_matches = [
|
||||
IpcCodeMatch(
|
||||
"subgroup",
|
||||
"C07C243/08",
|
||||
0.90,
|
||||
"organische Chemie",
|
||||
"topic",
|
||||
"TORG",
|
||||
)
|
||||
]
|
||||
|
||||
async def fake_search_epo(query):
|
||||
assert "match_phrase" in str(query) or "title_en" in str(query)
|
||||
return {
|
||||
"hits": {
|
||||
"hits": [
|
||||
{
|
||||
"_source": {
|
||||
"doc_number": "123",
|
||||
"country": "EP",
|
||||
"kind": "A1",
|
||||
"date_publication": "20240101",
|
||||
"title_en": patent.title,
|
||||
"abstract": patent.abstract,
|
||||
"ipc": patent.ipc,
|
||||
"cpc": [],
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
with patch(
|
||||
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
||||
new=AsyncMock(return_value=ipc_matches),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
||||
new=AsyncMock(side_effect=httpx.HTTPError("boom")),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
||||
new=AsyncMock(return_value={"hits": {"hits": []}}),
|
||||
):
|
||||
response = asyncio.run(get_patents_by_keywords(request))
|
||||
|
||||
async def fake_search_uspto(query):
|
||||
return {"hits": {"hits": []}}
|
||||
assert response.mapping_status == "search_error"
|
||||
assert response.patent_count == 0
|
||||
|
||||
|
||||
def test_no_ipc_search_terms_returns_without_text_fallback() -> None:
|
||||
"""Without usable IPC symbols the search abstains — no title/abstract path."""
|
||||
request = PatentsByKeywordsRequest(
|
||||
keywords=[
|
||||
KeywordPatentSearchItem(
|
||||
keyword="organische Chemie",
|
||||
keyword_level="coarse",
|
||||
topic_id="https://openalex.org/TORG",
|
||||
topic_display_name="Organic Chemistry",
|
||||
field_name="Chemistry",
|
||||
relevance_score=1.0,
|
||||
)
|
||||
]
|
||||
)
|
||||
search_epo = AsyncMock(return_value={"hits": {"hits": []}})
|
||||
search_uspto = AsyncMock(return_value={"hits": {"hits": []}})
|
||||
|
||||
with patch(
|
||||
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
||||
new=AsyncMock(return_value=[]),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
||||
new=search_epo,
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
||||
new=search_uspto,
|
||||
):
|
||||
response = asyncio.run(get_patents_by_keywords(request))
|
||||
|
||||
assert response.mapping_status == "no_mapping"
|
||||
assert response.patent_count == 0
|
||||
assert response.patents == []
|
||||
search_epo.assert_not_called()
|
||||
search_uspto.assert_not_called()
|
||||
|
||||
|
||||
def test_uncertain_ipc_cluster_abstention_returns_without_text_fallback() -> None:
|
||||
"""Fragmented IPC mapping abstains without falling back to text retrieval."""
|
||||
fragmented = [
|
||||
IpcCodeMatch(
|
||||
"subgroup",
|
||||
@@ -1074,113 +960,31 @@ def test_uncertain_mapping_uses_text_fallback_not_empty_list() -> None:
|
||||
)
|
||||
]
|
||||
)
|
||||
search_epo = AsyncMock(return_value={"hits": {"hits": []}})
|
||||
|
||||
with patch(
|
||||
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
||||
new=AsyncMock(return_value=fragmented),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
||||
new=AsyncMock(side_effect=fake_search_epo),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
||||
new=AsyncMock(side_effect=fake_search_uspto),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.PatentOpenAlexMappingResolver.resolve_topics_for_patents",
|
||||
new=AsyncMock(return_value={}),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.enrich_patents_classifications",
|
||||
new=AsyncMock(),
|
||||
), patch.object(
|
||||
IpcPatentSearchQueries,
|
||||
"epo_query_by_text_phrases",
|
||||
wraps=IpcPatentSearchQueries().epo_query_by_text_phrases,
|
||||
) as epo_text:
|
||||
response = asyncio.run(get_patents_by_keywords(request))
|
||||
|
||||
epo_text.assert_called_once()
|
||||
assert response.mapping_status == "uncertain"
|
||||
assert response.patent_count == 1
|
||||
assert response.patents[0].text_retrieval is True
|
||||
assert response.patents[0].ipc_score == 0.0
|
||||
assert response.patents[0].text_score > 0.0
|
||||
assert response.patents[0].matched_ipc_symbols == []
|
||||
assert response.patents[0].keyword_evidence is not None
|
||||
assert response.patents[0].keyword_evidence.phrase_in_title is True
|
||||
assert response.patents[0].keyword_evidence.text_match_kind == "phrase_title"
|
||||
|
||||
|
||||
def test_text_fallback_empty_yields_no_patents_found() -> None:
|
||||
request = PatentsByKeywordsRequest(
|
||||
keywords=[
|
||||
KeywordPatentSearchItem(
|
||||
keyword="organische Chemie",
|
||||
keyword_level="coarse",
|
||||
topic_id="https://openalex.org/TORG",
|
||||
topic_display_name="Organic Chemistry",
|
||||
field_name="Chemistry",
|
||||
relevance_score=1.0,
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
with patch(
|
||||
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
||||
new=AsyncMock(return_value=[]),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
||||
new=AsyncMock(return_value={"hits": {"hits": []}}),
|
||||
new=search_epo,
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
||||
new=AsyncMock(return_value={"hits": {"hits": []}}),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.PatentOpenAlexMappingResolver.resolve_topics_for_patents",
|
||||
new=AsyncMock(return_value={}),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.enrich_patents_classifications",
|
||||
new=AsyncMock(),
|
||||
):
|
||||
response = asyncio.run(get_patents_by_keywords(request))
|
||||
|
||||
assert response.mapping_status == "no_patents_found"
|
||||
assert response.mapping_status == "uncertain"
|
||||
assert response.patent_count == 0
|
||||
assert response.patents == []
|
||||
|
||||
|
||||
def test_technical_search_failure_returns_search_error_not_no_patents_found() -> None:
|
||||
request = PatentsByKeywordsRequest(
|
||||
keywords=[
|
||||
KeywordPatentSearchItem(
|
||||
keyword="organische Chemie",
|
||||
keyword_level="coarse",
|
||||
topic_id="https://openalex.org/TORG",
|
||||
topic_display_name="Organic Chemistry",
|
||||
field_name="Chemistry",
|
||||
relevance_score=1.0,
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
with patch(
|
||||
"inse.patents.keywords.logic.KeywordIpcReverseLookup.lookup_ipc_codes",
|
||||
new=AsyncMock(return_value=[]),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_epo",
|
||||
new=AsyncMock(side_effect=httpx.HTTPError("boom")),
|
||||
), patch(
|
||||
"inse.patents.keywords.logic.BasePatentSearchClient.search_uspto",
|
||||
new=AsyncMock(return_value={"hits": {"hits": []}}),
|
||||
):
|
||||
response = asyncio.run(get_patents_by_keywords(request))
|
||||
|
||||
assert response.mapping_status == "search_error"
|
||||
assert response.patent_count == 0
|
||||
search_epo.assert_not_called()
|
||||
|
||||
|
||||
def test_json_lookup_returns_empty_without_mapping(monkeypatch) -> None:
|
||||
clear_reverse_lookup_caches()
|
||||
monkeypatch.setattr(
|
||||
"inse.patents.keywords.reverse_lookup.load_patents_openalex_keywords_json",
|
||||
dict,
|
||||
lambda: {},
|
||||
)
|
||||
clear_reverse_lookup_caches()
|
||||
|
||||
|
||||
@@ -944,6 +944,7 @@ async def search_eu_cordis_projects(
|
||||
sort_by: str = "title",
|
||||
sort_direction: str = "asc",
|
||||
fuzzy: bool = False,
|
||||
skip_enrichment: bool = False,
|
||||
) -> EuCordisProjectSearchPage:
|
||||
"""
|
||||
Generic EU CORDIS project search across FP7, H2020 and Horizon Europe.
|
||||
@@ -1015,6 +1016,14 @@ async def search_eu_cordis_projects(
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
total = response.get("hits", {}).get("total", {}).get("value", 0)
|
||||
|
||||
if skip_enrichment:
|
||||
return EuCordisProjectSearchPage(
|
||||
elements=[EuCordisProjectSummary.from_hit(hit) for hit in hits],
|
||||
total=total,
|
||||
page=page,
|
||||
size=size,
|
||||
)
|
||||
|
||||
project_ids_by_type: dict[EuCordisProjectType, list[str]] = defaultdict(list)
|
||||
|
||||
for hit in hits:
|
||||
@@ -1333,4 +1342,4 @@ async def get_openalex_authors_for_projects_ids(
|
||||
result[(project_type, pid)] = author_pages_by_project_id.get(
|
||||
pid, AuthorPage(elements=[], total=0, page=0, size=0)
|
||||
)
|
||||
return result
|
||||
return result
|
||||
|
||||
@@ -359,6 +359,53 @@ async def get_person_institutes(
|
||||
}
|
||||
return result
|
||||
|
||||
async def get_dfg_institutes_by_ids(
|
||||
institute_ids: list[int],
|
||||
) -> dict[str, dict]:
|
||||
|
||||
if not institute_ids:
|
||||
return {}
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.DFG_INSTITUTES,
|
||||
cluster=ESCluster.INSE,
|
||||
body={
|
||||
"size": len(institute_ids),
|
||||
"_source": [
|
||||
"institute_id",
|
||||
"root_id",
|
||||
"root_name_de",
|
||||
"root_name_en",
|
||||
"institute_name_de",
|
||||
"institute_name_en",
|
||||
"address_country_de",
|
||||
"address_country_en",
|
||||
],
|
||||
"query": {
|
||||
"terms": {
|
||||
"_id": institute_ids,
|
||||
}
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
result = {}
|
||||
|
||||
for hit in response["hits"]["hits"]:
|
||||
source = hit["_source"]
|
||||
|
||||
result[source["institute_id"]] = {
|
||||
"institute_id": source["institute_id"],
|
||||
"root_id": source.get("root_id"),
|
||||
"root_name_de": source.get("root_name_de"),
|
||||
"root_name_en": source.get("root_name_en"),
|
||||
"institute_name_de": source.get("institute_name_de"),
|
||||
"institute_name_en": source.get("institute_name_en"),
|
||||
"address_country_de": source.get("address_country_de"),
|
||||
"address_country_en": source.get("address_country_en"),
|
||||
}
|
||||
return result
|
||||
|
||||
|
||||
#EU Cordis Projects
|
||||
|
||||
|
||||
@@ -250,12 +250,41 @@ class DfgProjectSummary(BaseModel):
|
||||
def from_hit(cls, hit: dict) -> "DfgProjectSummary":
|
||||
source = hit.get("_source", {})
|
||||
fields = hit.get("fields", {})
|
||||
|
||||
|
||||
names = []
|
||||
institutions = {}
|
||||
project_persons = []
|
||||
|
||||
persons = source.get("persons", [])
|
||||
institutions_raw= source.get("institutions", [])
|
||||
if isinstance(institutions_raw, list):
|
||||
for institution in institutions_raw:
|
||||
if not isinstance(institution, dict):
|
||||
continue
|
||||
|
||||
institute_id = institution.get("institute_id")
|
||||
if institute_id is not None:
|
||||
institutions[f"institute:{institute_id}"] = DfgInstitutionSummary(
|
||||
id=institute_id,
|
||||
institute_name_de=institution.get("institute_name_de"),
|
||||
institute_name_en=institution.get("institute_name_en"),
|
||||
address_country_de=institution.get("address_country_de"),
|
||||
address_country_en=institution.get("address_country_en"),
|
||||
root_id=institution.get("root_id"),
|
||||
root_name_de=institution.get("root_name_de"),
|
||||
root_name_en=institution.get("root_name_en"),
|
||||
)
|
||||
root_id = institution.get("root_id")
|
||||
if root_id is not None:
|
||||
institutions[f"root:{root_id}"] = DfgInstitutionSummary(
|
||||
id=root_id,
|
||||
institute_name_de=institution.get("root_name_de"),
|
||||
institute_name_en=institution.get("root_name_en"),
|
||||
address_country_de=institution.get("address_country_de"),
|
||||
address_country_en=institution.get("address_country_en"),
|
||||
root_id=None,
|
||||
root_name_de=None,
|
||||
root_name_en=None,
|
||||
)
|
||||
|
||||
if isinstance(persons, list):
|
||||
for person in persons:
|
||||
@@ -266,35 +295,35 @@ class DfgProjectSummary(BaseModel):
|
||||
|
||||
if full_name:
|
||||
names.append(full_name.strip())
|
||||
# previously we were creating institution objects for each person, but now we are using the institutions from the institutions_raw list
|
||||
#institution = None
|
||||
# if person.get("institute_id") is not None:
|
||||
# institute = DfgInstitutionSummary(
|
||||
# id=person["institute_id"],
|
||||
# institute_name_de=person.get("institute_name_de"),
|
||||
# institute_name_en=person.get("institute_name_en"),
|
||||
# address_country_de=person.get("address_country_de"),
|
||||
# address_country_en=person.get("address_country_en"),
|
||||
# root_id=None,
|
||||
# root_name_de=None,
|
||||
# root_name_en=None,
|
||||
# )
|
||||
|
||||
institution = None
|
||||
if person.get("institute_id") is not None:
|
||||
institute = DfgInstitutionSummary(
|
||||
id=person["institute_id"],
|
||||
institute_name_de=person.get("institute_name_de"),
|
||||
institute_name_en=person.get("institute_name_en"),
|
||||
address_country_de=person.get("address_country_de"),
|
||||
address_country_en=person.get("address_country_en"),
|
||||
root_id=None,
|
||||
root_name_de=None,
|
||||
root_name_en=None,
|
||||
)
|
||||
# institutions[f"institute:{person['institute_id']}"] = institute
|
||||
|
||||
institutions[f"institute:{person['institute_id']}"] = institute
|
||||
# if person.get("root_id") is not None:
|
||||
# root_institution = DfgInstitutionSummary(
|
||||
# id=person["root_id"],
|
||||
# institute_name_de=person.get("root_name_de"),
|
||||
# institute_name_en=person.get("root_name_en"),
|
||||
# address_country_de=person.get("address_country_de"),
|
||||
# address_country_en=person.get("address_country_en"),
|
||||
# root_id=None,
|
||||
# root_name_de=None,
|
||||
# root_name_en=None,
|
||||
# )
|
||||
|
||||
if person.get("root_id") is not None:
|
||||
root_institution = DfgInstitutionSummary(
|
||||
id=person["root_id"],
|
||||
institute_name_de=person.get("root_name_de"),
|
||||
institute_name_en=person.get("root_name_en"),
|
||||
address_country_de=person.get("address_country_de"),
|
||||
address_country_en=person.get("address_country_en"),
|
||||
root_id=None,
|
||||
root_name_de=None,
|
||||
root_name_en=None,
|
||||
)
|
||||
|
||||
institutions[f"root:{person['root_id']}"] = root_institution
|
||||
# institutions[f"root:{person['root_id']}"] = root_institution
|
||||
|
||||
if person.get("person_id") is not None:
|
||||
project_persons.append(
|
||||
@@ -305,7 +334,7 @@ class DfgProjectSummary(BaseModel):
|
||||
full_name=full_name,
|
||||
role_label_en=person.get("role_label_en"),
|
||||
role_label_de=person.get("role_label_de"),
|
||||
institution=institution,
|
||||
institution=None,
|
||||
)
|
||||
)
|
||||
topics_raw = source.get("topics") or []
|
||||
|
||||
@@ -15,6 +15,7 @@ from inse.projects.logic import (
|
||||
get_openalex_topics_for_bund_projects,
|
||||
get_openalex_topics_for_dfg_projects,
|
||||
get_person_ids_by_institution_ids,
|
||||
get_dfg_institutes_by_ids,
|
||||
get_person_institutes,
|
||||
)
|
||||
from inse.projects.model import (
|
||||
@@ -366,6 +367,7 @@ async def search_dfg_projects(
|
||||
sort_by: str = "id",
|
||||
sort_direction: str = "asc",
|
||||
fuzzy: bool = False,
|
||||
skip_enrichment: bool = False,
|
||||
) -> DfgProjectPage:
|
||||
"""Searches for DFG projects based on the provided filtering and sorting criteria.
|
||||
|
||||
@@ -411,6 +413,7 @@ async def search_dfg_projects(
|
||||
"subject_area_en",
|
||||
"persons",
|
||||
"subject_classifications",
|
||||
"institutions",
|
||||
],
|
||||
"query": {},
|
||||
}
|
||||
@@ -522,34 +525,54 @@ async def search_dfg_projects(
|
||||
)
|
||||
if not matching_institution_ids:
|
||||
return DfgProjectPage(elements=[], total=0, page=page, size=size)
|
||||
matching_person_ids = await get_person_ids_by_institution_ids(
|
||||
institution_ids=matching_institution_ids
|
||||
)
|
||||
#previously we were filtering by person_ids, but now we are filtering by institution_ids directly
|
||||
# matching_person_ids = await get_person_ids_by_institution_ids(
|
||||
# institution_ids=matching_institution_ids
|
||||
# )
|
||||
# must_clauses.append(
|
||||
# {
|
||||
# "nested": {
|
||||
# "path": "persons",
|
||||
# "query": {"terms": {"persons.person_id": matching_person_ids}},
|
||||
# }
|
||||
# }
|
||||
# )
|
||||
must_clauses.append(
|
||||
{
|
||||
"nested": {
|
||||
"path": "persons",
|
||||
"query": {"terms": {"persons.person_id": matching_person_ids}},
|
||||
"path": "institutions",
|
||||
"query": {"terms": {"institutions.institute_id": matching_institution_ids}},
|
||||
}
|
||||
}
|
||||
)
|
||||
print("MATCHING_INSTITUTION_IDS", matching_institution_ids)
|
||||
|
||||
if institution_ids:
|
||||
matching_person_ids = await get_person_ids_by_institution_ids(
|
||||
institution_ids=institution_ids
|
||||
)
|
||||
#prevously we were filtering by person_ids, but now we are filtering by institution_ids directly
|
||||
# matching_person_ids = await get_person_ids_by_institution_ids(
|
||||
# institution_ids=institution_ids
|
||||
# )
|
||||
|
||||
if not matching_person_ids:
|
||||
return DfgProjectPage(elements=[], total=0, page=page, size=size)
|
||||
# if not matching_person_ids:
|
||||
# return DfgProjectPage(elements=[], total=0, page=page, size=size)
|
||||
|
||||
# must_clauses.append(
|
||||
# {
|
||||
# "nested": {
|
||||
# "path": "persons",
|
||||
# "query": {"terms": {"persons.person_id": matching_person_ids}},
|
||||
# }
|
||||
# }
|
||||
# )
|
||||
must_clauses.append(
|
||||
{
|
||||
"nested": {
|
||||
"path": "persons",
|
||||
"query": {"terms": {"persons.person_id": matching_person_ids}},
|
||||
"path": "institutions",
|
||||
"query": {"terms": {"institutions.institute_id": institution_ids}},
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
body["query"] = (
|
||||
{"bool": {"must": must_clauses}} if must_clauses else {"match_all": {}}
|
||||
@@ -576,6 +599,7 @@ async def search_dfg_projects(
|
||||
body["sort"] = [sort_config]
|
||||
# print(f"Executing DFG project search with body: {json.dumps(body, indent=2)}")
|
||||
# === Execute Search ===
|
||||
print(f"Executing DFG project search with body: {json.dumps(body, indent=2)}")
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.DFG_PROJECTS,
|
||||
body=body,
|
||||
@@ -584,6 +608,9 @@ async def search_dfg_projects(
|
||||
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
|
||||
if skip_enrichment:
|
||||
return _complete_response_to_dfg_project_page(response, page, size)
|
||||
|
||||
project_ids = [hit["_source"]["id"] for hit in hits]
|
||||
topic_lookup = await get_openalex_topics_for_dfg_projects(project_ids=project_ids)
|
||||
|
||||
@@ -599,21 +626,28 @@ async def search_dfg_projects(
|
||||
source = hit["_source"]
|
||||
project_id = source["id"]
|
||||
source["topics"] = topic_lookup.get(str(project_id), [])
|
||||
institutions = source.get("institutions", [])
|
||||
for institution in institutions:
|
||||
institute_id = institution.get("institute_id")
|
||||
if institute_id is not None:
|
||||
institute_info = await get_dfg_institutes_by_ids(institute_ids=[institute_id])
|
||||
if institute_info:
|
||||
institution.update(institute_info[institute_id])
|
||||
persons = source.get("persons", [])
|
||||
for person in persons:
|
||||
person_id = person.get("person_id")
|
||||
institute = person_lookup.get(person_id)
|
||||
|
||||
if institute:
|
||||
person["root_id"] = institute.get("root_id")
|
||||
person["institute_id"] = institute.get("institute_id")
|
||||
person["root_name_de"] = institute.get("root_name_de")
|
||||
person["root_name_en"] = institute.get("root_name_en")
|
||||
person["institute_name_de"] = institute.get("institute_name_de")
|
||||
person["institute_name_en"] = institute.get("institute_name_en")
|
||||
person["address_country_de"] = institute.get("address_country_de")
|
||||
person["address_country_en"] = institute.get("address_country_en")
|
||||
|
||||
# if institute:
|
||||
# person["root_id"] = institute.get("root_id")
|
||||
# person["institute_id"] = institute.get("institute_id")
|
||||
# person["root_name_de"] = institute.get("root_name_de")
|
||||
# person["root_name_en"] = institute.get("root_name_en")
|
||||
# person["institute_name_de"] = institute.get("institute_name_de")
|
||||
# person["institute_name_en"] = institute.get("institute_name_en")
|
||||
# person["address_country_de"] = institute.get("address_country_de")
|
||||
# person["address_country_en"] = institute.get("address_country_en")
|
||||
print("ENRIECHED",source.get("institutions", []))
|
||||
return _complete_response_to_dfg_project_page(response, page, size)
|
||||
|
||||
def _complete_response_to_dfg_project_page(
|
||||
@@ -654,12 +688,128 @@ async def get_dfg_project_by_id(project_id: str) -> DfgProjectDetails | None:
|
||||
)
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
|
||||
if hits:
|
||||
hit = hits[0]
|
||||
hit["_source"]["topics"] = topic_lookup.get(project_id, [])
|
||||
details = DfgProjectDetails.from_elastic_hit(hit=hit)
|
||||
return details
|
||||
return None
|
||||
if not hits:
|
||||
return None
|
||||
|
||||
hit = hits[0]
|
||||
source = hit["_source"]
|
||||
source["topics"] = topic_lookup.get(project_id, [])
|
||||
|
||||
persons = source.get("persons", [])
|
||||
|
||||
# --- Enrich persons with institute/root info (mirrors search_dfg_projects) ---
|
||||
person_ids = {
|
||||
person["person_id"]
|
||||
for person in persons
|
||||
if isinstance(person, dict) and person.get("person_id") is not None
|
||||
}
|
||||
person_lookup = await get_person_institutes(person_ids=list(person_ids))
|
||||
|
||||
institutions: dict[str, dict] = {}
|
||||
|
||||
for person in persons:
|
||||
person_id = person.get("person_id")
|
||||
institute = person_lookup.get(person_id)
|
||||
if not institute:
|
||||
continue
|
||||
|
||||
person["root_id"] = institute.get("root_id")
|
||||
person["institute_id"] = institute.get("institute_id")
|
||||
person["root_name_de"] = institute.get("root_name_de")
|
||||
person["root_name_en"] = institute.get("root_name_en")
|
||||
person["institute_name_de"] = institute.get("institute_name_de")
|
||||
person["institute_name_en"] = institute.get("institute_name_en")
|
||||
person["address_country_de"] = institute.get("address_country_de")
|
||||
person["address_country_en"] = institute.get("address_country_en")
|
||||
|
||||
if institute.get("institute_id") is not None:
|
||||
institutions[f"institute:{institute['institute_id']}"] = {
|
||||
"institute_id": institute["institute_id"],
|
||||
"institute_name_de": institute.get("institute_name_de"),
|
||||
"institute_name_en": institute.get("institute_name_en"),
|
||||
}
|
||||
|
||||
if institute.get("root_id") is not None:
|
||||
institutions[f"root:{institute['root_id']}"] = {
|
||||
"institute_id": institute["root_id"],
|
||||
"institute_name_de": institute.get("root_name_de"),
|
||||
"institute_name_en": institute.get("root_name_en"),
|
||||
}
|
||||
|
||||
source["institutions"] = list(institutions.values())
|
||||
|
||||
return DfgProjectDetails.from_elastic_hit(hit=hit)
|
||||
|
||||
async def get_dfg_project_by_id(project_id: str) -> DfgProjectDetails | None:
|
||||
"""Fetches the details of a single DFG project based on its project ID.
|
||||
|
||||
Args:
|
||||
project_id (str): The project ID to fetch.
|
||||
|
||||
Returns:
|
||||
Optional[DfgProjectDetails]: The project details or None if not found.
|
||||
"""
|
||||
topic_lookup = await get_openalex_topics_for_dfg_projects(project_ids=[project_id])
|
||||
query = {"ids": {"values": [project_id]}}
|
||||
|
||||
response = await elasticsearch.search(
|
||||
index=ESIndex.DFG_PROJECTS,
|
||||
query=query,
|
||||
size=1,
|
||||
)
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
|
||||
if not hits:
|
||||
return None
|
||||
|
||||
hit = hits[0]
|
||||
source = hit["_source"]
|
||||
source["topics"] = topic_lookup.get(project_id, [])
|
||||
|
||||
persons = source.get("persons", [])
|
||||
|
||||
#Enrich persons with institute/root info
|
||||
person_ids = {
|
||||
person["person_id"]
|
||||
for person in persons
|
||||
if isinstance(person, dict) and person.get("person_id") is not None
|
||||
}
|
||||
person_lookup = await get_person_institutes(person_ids=list(person_ids))
|
||||
|
||||
institutions: dict[str, dict] = {}
|
||||
|
||||
for person in persons:
|
||||
person_id = person.get("person_id")
|
||||
institute = person_lookup.get(person_id)
|
||||
if not institute:
|
||||
continue
|
||||
|
||||
person["root_id"] = institute.get("root_id")
|
||||
person["institute_id"] = institute.get("institute_id")
|
||||
person["root_name_de"] = institute.get("root_name_de")
|
||||
person["root_name_en"] = institute.get("root_name_en")
|
||||
person["institute_name_de"] = institute.get("institute_name_de")
|
||||
person["institute_name_en"] = institute.get("institute_name_en")
|
||||
person["address_country_de"] = institute.get("address_country_de")
|
||||
person["address_country_en"] = institute.get("address_country_en")
|
||||
|
||||
if institute.get("institute_id") is not None:
|
||||
institutions[f"institute:{institute['institute_id']}"] = {
|
||||
"institute_id": institute["institute_id"],
|
||||
"institute_name_de": institute.get("institute_name_de"),
|
||||
"institute_name_en": institute.get("institute_name_en"),
|
||||
}
|
||||
|
||||
if institute.get("root_id") is not None:
|
||||
institutions[f"root:{institute['root_id']}"] = {
|
||||
"institute_id": institute["root_id"],
|
||||
"institute_name_de": institute.get("root_name_de"),
|
||||
"institute_name_en": institute.get("root_name_en"),
|
||||
}
|
||||
|
||||
source["institutions"] = list(institutions.values())
|
||||
|
||||
return DfgProjectDetails.from_elastic_hit(hit=hit)
|
||||
|
||||
#BUND
|
||||
|
||||
@@ -1051,4 +1201,4 @@ def _hit_to_funding_project(hit: dict[str, Any]) -> FundingProject:
|
||||
else:
|
||||
raise ValueError(
|
||||
"The provided hit does not belong to a recognized project index."
|
||||
)
|
||||
)
|
||||
|
||||
@@ -174,6 +174,7 @@ async def get_dfg_projects_by_author_id(
|
||||
sort_by: str = "topic",
|
||||
sort_direction: str = "asc",
|
||||
fuzzy: bool = False,
|
||||
skip_enrichment: bool = False,
|
||||
) -> DfgProjectPage:
|
||||
logger.debug(
|
||||
"Fetching DFG projects for author_id=%s, author_filter_ids=%s, "
|
||||
@@ -248,6 +249,7 @@ async def get_dfg_projects_by_author_id(
|
||||
sort_by=sort_by,
|
||||
sort_direction=sort_direction,
|
||||
fuzzy=fuzzy,
|
||||
skip_enrichment=skip_enrichment,
|
||||
)
|
||||
|
||||
async def get_institution_cordis_eu_projects_funding_over_time(
|
||||
@@ -623,6 +625,7 @@ async def search_eu_cordis_projects(
|
||||
sort_by: str = "title",
|
||||
sort_direction: str = "asc",
|
||||
fuzzy: bool = False,
|
||||
skip_enrichment: bool = False,
|
||||
) -> EuCordisProjectSearchPage:
|
||||
"""Single entry point for EU CORDIS project search.
|
||||
|
||||
@@ -683,4 +686,5 @@ async def search_eu_cordis_projects(
|
||||
sort_by=sort_by,
|
||||
sort_direction=sort_direction,
|
||||
fuzzy=fuzzy,
|
||||
)
|
||||
skip_enrichment=skip_enrichment,
|
||||
)
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
import asyncio
|
||||
import logging
|
||||
from dataclasses import dataclass
|
||||
from math import floor
|
||||
from time import time
|
||||
from typing import Any
|
||||
|
||||
import pandas as pd
|
||||
|
||||
from inse.authors.institution_membership_query import (
|
||||
build_active_institution_membership_query,
|
||||
)
|
||||
@@ -746,15 +745,29 @@ def _bucket_to_ranked_author(author_bucket: dict) -> RankedAuthor:
|
||||
)
|
||||
|
||||
|
||||
def _min_max_normalize(values: pd.Series) -> pd.Series:
|
||||
def _quantile(values: list[float], quantile: float) -> float:
|
||||
"""Returns a linearly interpolated quantile (the former pandas default)."""
|
||||
ordered = sorted(values)
|
||||
if not ordered:
|
||||
return 0.0
|
||||
position = (len(ordered) - 1) * quantile
|
||||
lower_index = floor(position)
|
||||
upper_index = min(lower_index + 1, len(ordered) - 1)
|
||||
fraction = position - lower_index
|
||||
return ordered[lower_index] + (
|
||||
ordered[upper_index] - ordered[lower_index]
|
||||
) * fraction
|
||||
|
||||
|
||||
def _min_max_normalize(values: list[float]) -> list[float]:
|
||||
"""Scales a numeric column to the range [0, 1] via min-max normalization."""
|
||||
minimum = values.min()
|
||||
maximum = values.max()
|
||||
minimum = min(values)
|
||||
maximum = max(values)
|
||||
# if all values are the same, return a series of 1.0 to avoid division by zero.
|
||||
if maximum == minimum:
|
||||
return pd.Series([1.0] * len(values))
|
||||
return [1.0] * len(values)
|
||||
|
||||
return (values - minimum) / (maximum - minimum)
|
||||
return [(value - minimum) / (maximum - minimum) for value in values]
|
||||
|
||||
|
||||
def _apply_scores(authors: list[RankedAuthor], weights: RankingWeights) -> None:
|
||||
@@ -775,38 +788,29 @@ def _apply_scores(authors: list[RankedAuthor], weights: RankingWeights) -> None:
|
||||
news_counts.append(author.news_count)
|
||||
patents_counts.append(author.patents_count)
|
||||
|
||||
frame = pd.DataFrame({
|
||||
"works": works_counts,
|
||||
"citations": citations_counts,
|
||||
"companies": companies_counts,
|
||||
"news": news_counts,
|
||||
"patents": patents_counts,
|
||||
})
|
||||
|
||||
quantile_value = 0.95
|
||||
|
||||
frame["works"] = frame["works"].clip(upper=frame["works"].quantile(quantile_value))
|
||||
frame["citations"] = frame["citations"].clip(upper=frame["citations"].quantile(quantile_value))
|
||||
frame["companies"] = frame["companies"].clip(upper=frame["companies"].quantile(quantile_value))
|
||||
frame["news"] = frame["news"].clip(upper=frame["news"].quantile(quantile_value))
|
||||
frame["patents"] = frame["patents"].clip(upper=frame["patents"].quantile(quantile_value))
|
||||
|
||||
works_normalized = _min_max_normalize(frame["works"])
|
||||
citations_normalized = _min_max_normalize(frame["citations"])
|
||||
companies_normalized = _min_max_normalize(frame["companies"])
|
||||
news_normalized = _min_max_normalize(frame["news"])
|
||||
patents_normalized = _min_max_normalize(frame["patents"])
|
||||
|
||||
scores = (
|
||||
works_normalized * weights.works
|
||||
+ citations_normalized * weights.citation
|
||||
+ companies_normalized * weights.companies
|
||||
+ news_normalized * weights.news
|
||||
+ patents_normalized * weights.patents
|
||||
)
|
||||
metrics = [
|
||||
works_counts,
|
||||
citations_counts,
|
||||
companies_counts,
|
||||
news_counts,
|
||||
patents_counts,
|
||||
]
|
||||
normalized_metrics = [
|
||||
_min_max_normalize(
|
||||
[min(value, _quantile(values, quantile_value)) for value in values]
|
||||
)
|
||||
for values in metrics
|
||||
]
|
||||
|
||||
for index, author in enumerate(authors):
|
||||
author.score = float(scores.iloc[index])
|
||||
author.score = float(
|
||||
normalized_metrics[0][index] * weights.works
|
||||
+ normalized_metrics[1][index] * weights.citation
|
||||
+ normalized_metrics[2][index] * weights.companies
|
||||
+ normalized_metrics[3][index] * weights.news
|
||||
+ normalized_metrics[4][index] * weights.patents
|
||||
)
|
||||
|
||||
|
||||
def _author_score(author: RankedAuthor) -> float:
|
||||
|
||||
@@ -24,7 +24,7 @@ router = APIRouter(prefix=RouterPrefixes.WORKS_V2, tags=[Tags.WORKS_V2])
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{raw_oa_work_id}",
|
||||
"/single/{raw_oa_work_id}",
|
||||
operation_id="getWorkById",
|
||||
summary="Returns a work based on its ID.",
|
||||
)
|
||||
|
||||
@@ -103,11 +103,11 @@ model/dfgPersonSummary.ts
|
||||
model/dfgPersonSummaryPage.ts
|
||||
model/dfgProjectDetails.ts
|
||||
model/dfgProjectInstitutionRole.ts
|
||||
model/dfgProjectKeyword.ts
|
||||
model/dfgProjectPage.ts
|
||||
model/dfgProjectPersonRole.ts
|
||||
model/dfgProjectPublicationSummary.ts
|
||||
model/dfgProjectStatusStatistics.ts
|
||||
model/dfgProjectSubjectArea.ts
|
||||
model/dfgProjectSubprojectSummary.ts
|
||||
model/dfgProjectSummary.ts
|
||||
model/dfgProjectTopic.ts
|
||||
|
||||
@@ -65,6 +65,71 @@ export class AuthService extends BaseService {
|
||||
super(basePath, configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user can fetch GDPR-relevant data
|
||||
* Check if the authenticated user can fetch GDPR-relevant data for a given author and institution.
|
||||
* @endpoint get /api/auth/v2/can-fetch-gdpr-relevant-data
|
||||
* @param rawOaAuthorId OpenAlex author ID to check access for
|
||||
* @param rawOaInstitutionId OpenAlex institution ID to check access for
|
||||
* @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 canFetchGdprRelevantData(rawOaAuthorId?: string, rawOaInstitutionId?: string, secureFgpAcc?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<boolean>;
|
||||
public canFetchGdprRelevantData(rawOaAuthorId?: string, rawOaInstitutionId?: string, secureFgpAcc?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<boolean>>;
|
||||
public canFetchGdprRelevantData(rawOaAuthorId?: string, rawOaInstitutionId?: string, secureFgpAcc?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<boolean>>;
|
||||
public canFetchGdprRelevantData(rawOaAuthorId?: string, rawOaInstitutionId?: string, secureFgpAcc?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
|
||||
let localVarQueryParameters = new HttpParams({encoder: this.encoder});
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>rawOaAuthorId, 'raw_oa_author_id');
|
||||
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
|
||||
<any>rawOaInstitutionId, 'raw_oa_institution_id');
|
||||
|
||||
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;
|
||||
|
||||
|
||||
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/auth/v2/can-fetch-gdpr-relevant-data`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<boolean>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
params: localVarQueryParameters,
|
||||
responseType: <any>responseType_,
|
||||
...(withCredentials ? { withCredentials } : {}),
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change Password
|
||||
* Change the user\'s password and invalidate existing tokens.
|
||||
|
||||
@@ -511,7 +511,7 @@ export class WorksV2Service extends BaseService {
|
||||
|
||||
/**
|
||||
* Returns a work based on its ID.
|
||||
* @endpoint get /api/works/v2/{raw_oa_work_id}
|
||||
* @endpoint get /api/works/v2/single/{raw_oa_work_id}
|
||||
* @param rawOaWorkId The raw OpenAlex work id.
|
||||
* @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.
|
||||
@@ -549,7 +549,7 @@ export class WorksV2Service extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/works/v2/${this.configuration.encodeParam({name: "rawOaWorkId", value: rawOaWorkId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
let localVarPath = `/api/works/v2/single/${this.configuration.encodeParam({name: "rawOaWorkId", value: rawOaWorkId, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`;
|
||||
const { basePath, withCredentials } = this.configuration;
|
||||
return this.httpClient.request<Work>('get', `${basePath}${localVarPath}`,
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import { DfgProjectPersonRole } from './dfgProjectPersonRole';
|
||||
import { DfgProjectSubprojectSummary } from './dfgProjectSubprojectSummary';
|
||||
import { DfgProjectInstitutionRole } from './dfgProjectInstitutionRole';
|
||||
import { DfgProjectSubjectArea } from './dfgProjectSubjectArea';
|
||||
import { DFGProjectFachgebieteInner } from './dFGProjectFachgebieteInner';
|
||||
import { Topic } from './topic';
|
||||
import { DfgProjectPublicationSummary } from './dfgProjectPublicationSummary';
|
||||
|
||||
@@ -49,7 +49,7 @@ export interface DfgProjectDetails {
|
||||
/**
|
||||
* Detailed DFG subject-area classification entries (Fachsystematik)
|
||||
*/
|
||||
subject_classifications?: Array<DfgProjectSubjectArea>;
|
||||
subject_classifications?: Array<DFGProjectFachgebieteInner>;
|
||||
international_relation_de?: string | null;
|
||||
international_relation_en?: string | null;
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
export interface DfgProjectKeyword {
|
||||
name: string;
|
||||
project_count: number;
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* A single subject-area classification entry (DFG \'Fachsystematik\').
|
||||
*/
|
||||
export interface DfgProjectSubjectArea {
|
||||
fach?: string | null;
|
||||
fachgebiet?: string | null;
|
||||
fachkollegium?: string | null;
|
||||
wissenschaftsbereich?: string | null;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
import { DfgProjectKeyword } from './dfgProjectKeyword';
|
||||
|
||||
|
||||
export interface DfgProjectTopic {
|
||||
@@ -16,5 +17,6 @@ export interface DfgProjectTopic {
|
||||
field?: string | null;
|
||||
domain?: string | null;
|
||||
project_count: number;
|
||||
keywords: Array<DfgProjectKeyword>;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,11 +68,11 @@ export * from './dfgPersonSummary';
|
||||
export * from './dfgPersonSummaryPage';
|
||||
export * from './dfgProjectDetails';
|
||||
export * from './dfgProjectInstitutionRole';
|
||||
export * from './dfgProjectKeyword';
|
||||
export * from './dfgProjectPage';
|
||||
export * from './dfgProjectPersonRole';
|
||||
export * from './dfgProjectPublicationSummary';
|
||||
export * from './dfgProjectStatusStatistics';
|
||||
export * from './dfgProjectSubjectArea';
|
||||
export * from './dfgProjectSubprojectSummary';
|
||||
export * from './dfgProjectSummary';
|
||||
export * from './dfgProjectTopic';
|
||||
|
||||
@@ -6,7 +6,6 @@ import { personPatentsResolver } from './resolvers/person-patents.resolver';
|
||||
import { personResolver } from './resolvers/person.resolver';
|
||||
import { personNewsResolver } from './resolvers/person-news.resolver';
|
||||
import { institutionResolver } from './resolvers/institution.resolver';
|
||||
import { bundProjectPageResolver } from './resolvers/bund-project-page.resolver';
|
||||
import {
|
||||
dfgProjectsResolver,
|
||||
RESOLVING_PROJECT_PAGE_FOR,
|
||||
@@ -65,6 +64,7 @@ import {
|
||||
topicQueryParamKeys,
|
||||
} from './resolvers/topic-page.resolver';
|
||||
import { topicResolver } from './resolvers/topic.resolver';
|
||||
import { canFetchGdprRelevantDataResolver } from './resolvers/can-fetch-gdpr-relevant-data.resolver';
|
||||
export const routes: Routes = [
|
||||
{
|
||||
path: '',
|
||||
@@ -493,6 +493,7 @@ export const routes: Routes = [
|
||||
personData: personResolver,
|
||||
personBio: personBioResolver,
|
||||
personPatents: personPatentsResolver,
|
||||
canFetchGdprRelevantData: canFetchGdprRelevantDataResolver,
|
||||
},
|
||||
runGuardsAndResolvers: (from, to) => from.params['id'] !== to.params['id'],
|
||||
children: [
|
||||
@@ -658,16 +659,12 @@ export const routes: Routes = [
|
||||
import('./modules/institution/institution.component').then(
|
||||
(mod) => mod.InstitutionComponent,
|
||||
),
|
||||
resolve: { institution: institutionResolver },
|
||||
resolve: {
|
||||
institution: institutionResolver,
|
||||
canFetchGdprRelevantData: canFetchGdprRelevantDataResolver,
|
||||
},
|
||||
children: [
|
||||
{ path: '', pathMatch: 'full', redirectTo: 'overview' },
|
||||
{
|
||||
path: 'overview',
|
||||
loadComponent: () =>
|
||||
import('./modules/institution-overview/institution-overview.component').then(
|
||||
(mod) => mod.InstitutionOverviewComponent,
|
||||
),
|
||||
},
|
||||
{ path: '', pathMatch: 'full', redirectTo: 'publications' },
|
||||
{
|
||||
path: 'publications',
|
||||
loadComponent: () =>
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
</header>
|
||||
|
||||
@if (loading()) {
|
||||
<div class="loading-state">
|
||||
<mat-spinner diameter="42"></mat-spinner>
|
||||
<p>Bookmarks werden geladen …</p>
|
||||
</div>
|
||||
<app-loading
|
||||
text="Bookmarks werden geladen …"
|
||||
icon="bookmarks"
|
||||
[size]="60"
|
||||
[diameter]="60" />
|
||||
} @else if (persons().length) {
|
||||
<section class="person-grid" aria-label="Gespeicherte Personen">
|
||||
@for (person of persons(); track person.id) {
|
||||
|
||||
@@ -65,7 +65,6 @@
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.loading-state,
|
||||
.empty-state {
|
||||
display: flex;
|
||||
min-height: 320px;
|
||||
|
||||
@@ -2,12 +2,12 @@ import { CommonModule } from '@angular/common';
|
||||
import { Component, DestroyRef, inject, signal } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { catchError, forkJoin, map, of, switchMap } from 'rxjs';
|
||||
|
||||
import { CustomAuthor, PersonsService } from '../../api';
|
||||
import { BookmarkService } from '../../shared/services/bookmark.service';
|
||||
import { PersonCardComponent } from '../person-card/person-card.component';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
|
||||
const PERSON_INCLUDE_TAGS =
|
||||
'display_name,works_count,cited_by_count,summary_stats,ids,' +
|
||||
@@ -17,12 +17,7 @@ const PERSON_INCLUDE_TAGS =
|
||||
@Component({
|
||||
selector: 'app-bookmarks',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
PersonCardComponent,
|
||||
],
|
||||
imports: [CommonModule, MatIconModule, PersonCardComponent, LoadingComponent],
|
||||
templateUrl: './bookmarks.component.html',
|
||||
styleUrl: './bookmarks.component.scss',
|
||||
})
|
||||
|
||||
@@ -108,7 +108,7 @@ export class DashboardComponent implements OnInit {
|
||||
readonly topicTreemapMinYear = 1900;
|
||||
readonly topicTreemapMaxYear = new Date().getFullYear();
|
||||
dashboardPeriodMode: DashboardPeriodMode = 'all_time';
|
||||
dashboardFromYear = this.topicTreemapMaxYear - 4;
|
||||
dashboardFromYear = this.topicTreemapMinYear;
|
||||
dashboardToYear = this.topicTreemapMaxYear;
|
||||
selectedTopicTreemapNode?: string;
|
||||
selectedDfgTopicTreemapNode?: string;
|
||||
@@ -406,14 +406,16 @@ export class DashboardComponent implements OnInit {
|
||||
this.dashboardPeriodMode = mode;
|
||||
}
|
||||
this.applyPresetPeriod();
|
||||
this.dashboardFromYear = this.parseDashboardYear(
|
||||
params.get('fromYear'),
|
||||
this.dashboardFromYear,
|
||||
);
|
||||
this.dashboardToYear = this.parseDashboardYear(
|
||||
params.get('toYear'),
|
||||
this.dashboardToYear,
|
||||
);
|
||||
if (this.dashboardPeriodMode !== 'all_time') {
|
||||
this.dashboardFromYear = this.parseDashboardYear(
|
||||
params.get('fromYear'),
|
||||
this.dashboardFromYear,
|
||||
);
|
||||
this.dashboardToYear = this.parseDashboardYear(
|
||||
params.get('toYear'),
|
||||
this.dashboardToYear,
|
||||
);
|
||||
}
|
||||
if (this.dashboardFromYear > this.dashboardToYear) {
|
||||
this.dashboardFromYear = this.dashboardToYear;
|
||||
}
|
||||
@@ -422,7 +424,10 @@ export class DashboardComponent implements OnInit {
|
||||
|
||||
private applyPresetPeriod(): void {
|
||||
const currentYear = this.topicTreemapMaxYear;
|
||||
if (this.dashboardPeriodMode === 'last_10_years') {
|
||||
if (this.dashboardPeriodMode === 'all_time') {
|
||||
this.dashboardFromYear = this.topicTreemapMinYear;
|
||||
this.dashboardToYear = currentYear;
|
||||
} else if (this.dashboardPeriodMode === 'last_10_years') {
|
||||
this.dashboardFromYear = currentYear - 9;
|
||||
this.dashboardToYear = currentYear;
|
||||
} else if (this.dashboardPeriodMode === 'last_5_years') {
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<p>institution-overview works!</p>
|
||||
@@ -1,22 +0,0 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { InstitutionOverviewComponent } from './institution-overview.component';
|
||||
|
||||
describe('InstitutionOverviewComponent', () => {
|
||||
let component: InstitutionOverviewComponent;
|
||||
let fixture: ComponentFixture<InstitutionOverviewComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [InstitutionOverviewComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(InstitutionOverviewComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-institution-overview',
|
||||
imports: [],
|
||||
templateUrl: './institution-overview.component.html',
|
||||
styleUrl: './institution-overview.component.scss',
|
||||
})
|
||||
export class InstitutionOverviewComponent {}
|
||||
@@ -103,24 +103,29 @@
|
||||
{{ getMatchTypeLabel(patent) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="cell-authors">
|
||||
@if (
|
||||
patent.matched_authors && patent.matched_authors.length
|
||||
) {
|
||||
@for (
|
||||
author of patent.matched_authors.slice(0, 2);
|
||||
track author.openalex_author_id
|
||||
<td>
|
||||
<div class="cell-authors">
|
||||
@if (
|
||||
patent.matched_authors && patent.matched_authors.length
|
||||
) {
|
||||
<a
|
||||
class="author-link"
|
||||
[routerLink]="['/person', author.openalex_author_id]"
|
||||
(click)="$event.stopPropagation()">
|
||||
{{ author.author_name }}
|
||||
</a>
|
||||
@for (
|
||||
author of patent.matched_authors.slice(0, 2);
|
||||
track author.openalex_author_id
|
||||
) {
|
||||
<a
|
||||
class="author-link"
|
||||
[routerLink]="[
|
||||
'/person',
|
||||
author.openalex_author_id,
|
||||
]"
|
||||
(click)="$event.stopPropagation()">
|
||||
{{ author.author_name }}
|
||||
</a>
|
||||
}
|
||||
} @else {
|
||||
<span>-</span>
|
||||
}
|
||||
} @else {
|
||||
<span>-</span>
|
||||
}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@@ -60,21 +60,14 @@ app-query-param-paginator {
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
overflow: hidden;
|
||||
border-collapse: collapse;
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding: 12px 16px;
|
||||
background: var(--sg-surface-muted);
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
@@ -90,10 +83,6 @@ app-query-param-paginator {
|
||||
&.selected td {
|
||||
background: var(--sg-primary-soft);
|
||||
}
|
||||
|
||||
&:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
@@ -107,10 +96,9 @@ app-query-param-paginator {
|
||||
.patent-title {
|
||||
color: var(--sg-text);
|
||||
font-weight: 600;
|
||||
max-width: 280px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 320px;
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.cell-preview {
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
<a
|
||||
matTabLink
|
||||
[routerLink]="[route.path]"
|
||||
[queryParams]="{
|
||||
authorId: null,
|
||||
institutionId: null,
|
||||
agency: null,
|
||||
}"
|
||||
queryParamsHandling="merge"
|
||||
routerLinkActive
|
||||
#rla="routerLinkActive"
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<div class="content">
|
||||
<h1>{{ institution.display_name }}</h1>
|
||||
<h1>{{ institution().display_name }}</h1>
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-content>
|
||||
<p>{{ institution.homepage_url }}</p>
|
||||
<p>{{ institution.display_name_alternatives }}</p>
|
||||
<p>{{ institution().homepage_url }}</p>
|
||||
<p>{{ institution().display_name_alternatives }}</p>
|
||||
<p>And many more useful details...</p>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<nav mat-tab-nav-bar [tabPanel]="tabPanel">
|
||||
@for (link of links; track link.path) {
|
||||
@for (link of _links(); track link.path) {
|
||||
<a
|
||||
mat-tab-link
|
||||
[routerLink]="link.path"
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
import { Component, OnInit, inject } from '@angular/core';
|
||||
import {
|
||||
ActivatedRoute,
|
||||
RouterLink,
|
||||
RouterOutlet,
|
||||
RouterLinkActive,
|
||||
} from '@angular/router';
|
||||
import { Component, computed, input } from '@angular/core';
|
||||
import { RouterLink, RouterOutlet, RouterLinkActive } from '@angular/router';
|
||||
import { Institution } from '../../api';
|
||||
import { PatentsService } from '../../api/api/patents.service';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatTabsModule } from '@angular/material/tabs';
|
||||
|
||||
const PATENTS_LINK = { label: 'Patente', path: 'patents', disabled: false };
|
||||
type TabLink = {
|
||||
label: string;
|
||||
path: string;
|
||||
disabled: boolean;
|
||||
queryParams?: Record<string, any>;
|
||||
};
|
||||
|
||||
@Component({
|
||||
selector: 'app-institution',
|
||||
@@ -24,51 +23,32 @@ const PATENTS_LINK = { label: 'Patente', path: 'patents', disabled: false };
|
||||
templateUrl: './institution.component.html',
|
||||
styleUrl: './institution.component.scss',
|
||||
})
|
||||
export class InstitutionComponent implements OnInit {
|
||||
private readonly patentsApi = inject(PatentsService);
|
||||
export class InstitutionComponent {
|
||||
institution = input.required<Institution>();
|
||||
canFetchGdprRelevantData = input.required<boolean>();
|
||||
|
||||
institution!: Institution;
|
||||
|
||||
links = [
|
||||
{ label: 'Übersicht', path: 'overview', disabled: false },
|
||||
{ label: 'Publikationen', path: 'publications', disabled: false },
|
||||
{
|
||||
label: 'Projekte',
|
||||
path: 'projects',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
project_tab: 'bund',
|
||||
page: 0,
|
||||
size: 10,
|
||||
search: '',
|
||||
sort_by: 'title',
|
||||
sort_direction: 'asc',
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
constructor(private readonly activatedRoute: ActivatedRoute) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.activatedRoute.data.subscribe(({ institution }) => {
|
||||
this.institution = institution;
|
||||
});
|
||||
|
||||
const institutionId =
|
||||
this.activatedRoute.snapshot.paramMap.get('institutionId');
|
||||
if (!institutionId) return;
|
||||
|
||||
// The "Patente" tab only makes sense once org_patents has been indexed for
|
||||
// this institution (currently a manual, ~30-40 min-per-institution process),
|
||||
// so only show it once we know there is actually data behind it.
|
||||
this.patentsApi
|
||||
.getOrgPatentsByInstitution(institutionId, undefined, 0, 0)
|
||||
.subscribe({
|
||||
next: (result) => {
|
||||
if ((result.patent_count ?? 0) > 0) {
|
||||
this.links = [...this.links, PATENTS_LINK];
|
||||
}
|
||||
_links = computed<TabLink[]>(() => {
|
||||
const links: TabLink[] = [
|
||||
{ label: 'Publikationen', path: 'publications', disabled: false },
|
||||
];
|
||||
if (this.canFetchGdprRelevantData()) {
|
||||
links.push(
|
||||
{
|
||||
label: 'Projekte',
|
||||
path: 'projects',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
project_tab: 'bund',
|
||||
page: 0,
|
||||
size: 10,
|
||||
search: '',
|
||||
sort_by: 'title',
|
||||
sort_direction: 'asc',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
{ label: 'Patente', path: 'patents', disabled: false },
|
||||
);
|
||||
}
|
||||
return links;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
<mat-dialog-content>
|
||||
@if (runsLoading() && runs().length === 0) {
|
||||
<div class="runs-loading">
|
||||
<mat-progress-spinner
|
||||
diameter="24"
|
||||
mode="indeterminate"></mat-progress-spinner>
|
||||
<span>Läufe werden geladen …</span>
|
||||
</div>
|
||||
<app-loading
|
||||
text="Läufe werden geladen …"
|
||||
icon="history"
|
||||
[size]="48"
|
||||
[diameter]="48" />
|
||||
} @else if (runsError()) {
|
||||
<p class="logs-error">{{ runsError() }}</p>
|
||||
} @else if (runs().length === 0) {
|
||||
@@ -79,12 +78,11 @@
|
||||
|
||||
<div #logsPanel class="logs-panel" (scroll)="onLogsScroll()">
|
||||
@if (loading() && !logs()) {
|
||||
<div class="logs-loading">
|
||||
<mat-progress-spinner
|
||||
diameter="20"
|
||||
mode="indeterminate"></mat-progress-spinner>
|
||||
<span>Logs werden geladen …</span>
|
||||
</div>
|
||||
<app-loading
|
||||
text="Logs werden geladen …"
|
||||
icon="description"
|
||||
[size]="48"
|
||||
[diameter]="48" />
|
||||
} @else {
|
||||
<pre>{{ logs() }}</pre>
|
||||
}
|
||||
|
||||
@@ -3,14 +3,6 @@
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.runs-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-height: 120px;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.logs-error {
|
||||
margin: 0;
|
||||
padding: 16px;
|
||||
@@ -93,18 +85,6 @@
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.logs-loading {
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
}
|
||||
|
||||
.logs-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.run-select {
|
||||
|
||||
@@ -18,11 +18,11 @@ import {
|
||||
} from '@angular/material/dialog';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { finalize, timer } from 'rxjs';
|
||||
import { BackgroundJobsService, BackgroundJobTask, JobRun } from '../../../api';
|
||||
import { LoadingComponent } from '../../../shared/ui/loading/loading.component';
|
||||
import {
|
||||
formatRunDuration,
|
||||
formatRunElapsed,
|
||||
@@ -42,9 +42,9 @@ export interface JobLogsDialogData {
|
||||
MatDialogModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatSelectModule,
|
||||
MatTooltipModule,
|
||||
LoadingComponent,
|
||||
],
|
||||
templateUrl: './job-logs-dialog.component.html',
|
||||
styleUrl: './job-logs-dialog.component.scss',
|
||||
|
||||
+83
-86
@@ -1,46 +1,63 @@
|
||||
@if (loading()) {
|
||||
<div class="patents-container">
|
||||
<ng-container *ngTemplateOutlet="patentsHeader" />
|
||||
<app-loading
|
||||
text="Patentdaten werden geladen..."
|
||||
icon="workspace_premium"
|
||||
[size]="150"
|
||||
[diameter]="150" />
|
||||
</div>
|
||||
<app-loading
|
||||
text="Patentdaten werden geladen..."
|
||||
icon="workspace_premium"
|
||||
[size]="150"
|
||||
[diameter]="150" />
|
||||
} @else if (error()) {
|
||||
<div class="patents-container">
|
||||
<ng-container *ngTemplateOutlet="patentsHeader" />
|
||||
<p class="message">Fehler beim Laden der Patente.</p>
|
||||
</div>
|
||||
<p class="message">Fehler beim Laden der Patente.</p>
|
||||
} @else if (matches().length === 0) {
|
||||
<div class="patents-container">
|
||||
<ng-container *ngTemplateOutlet="patentsHeader" />
|
||||
<p class="message">{{ emptyMessage() }}</p>
|
||||
</div>
|
||||
<p class="message">{{ emptyMessage() }}</p>
|
||||
} @else {
|
||||
<div class="patents-container">
|
||||
<ng-container *ngTemplateOutlet="patentsHeader" />
|
||||
|
||||
<div class="patents-content">
|
||||
<div class="patents-list">
|
||||
<div class="patents-list-toolbar">
|
||||
<mat-form-field
|
||||
class="patents-toolbar-field"
|
||||
subscriptSizing="dynamic">
|
||||
<mat-icon matPrefix fontIcon="filter_alt"></mat-icon>
|
||||
<mat-select
|
||||
[value]="activeFilter()"
|
||||
(selectionChange)="setFilter($event.value)">
|
||||
<mat-select-trigger>Filter nach Quelle</mat-select-trigger>
|
||||
<mat-option value="all">Alle</mat-option>
|
||||
<mat-option value="EPO">EPO</mat-option>
|
||||
<mat-option value="USPTO">USPTO</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
<mat-form-field
|
||||
class="patents-toolbar-field"
|
||||
subscriptSizing="dynamic">
|
||||
<mat-icon matPrefix fontIcon="sort"></mat-icon>
|
||||
<mat-select
|
||||
[value]="sortMode()"
|
||||
(selectionChange)="setSortMode($event.value)">
|
||||
<mat-select-trigger>Sortieren nach</mat-select-trigger>
|
||||
<mat-option value="date">Datum</mat-option>
|
||||
<mat-option value="title">Titel</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Patent</th>
|
||||
<th>Score</th>
|
||||
<th>Quelle</th>
|
||||
<th>Jahr</th>
|
||||
<th>Erfinder</th>
|
||||
<th>Anmelder</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (item of pagedMatches(); track trackMatch($index, item)) {
|
||||
@for (item of getPagedMatches(); track trackMatch($index, item)) {
|
||||
<tr
|
||||
[class.selected]="selectedMatch() === item"
|
||||
(click)="selectMatch(item)">
|
||||
<td class="patent-title">
|
||||
{{ item.patent.title ?? item.patent.patent_id }}
|
||||
</td>
|
||||
<td class="match-score">{{ formatScore(item.match_score) }}</td>
|
||||
<td>
|
||||
<span
|
||||
class="source-badge source-badge--{{
|
||||
@@ -50,50 +67,33 @@
|
||||
</span>
|
||||
</td>
|
||||
<td>{{ item.patent.publication_year ?? '-' }}</td>
|
||||
<td
|
||||
class="patent-people"
|
||||
[title]="getInventorsLabel(item.patent)">
|
||||
{{ getInventorsLabel(item.patent) }}
|
||||
</td>
|
||||
<td
|
||||
class="patent-people"
|
||||
[title]="getAssigneesLabel(item.patent)">
|
||||
{{ getAssigneesLabel(item.patent) }}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@if (hasPagination()) {
|
||||
<div class="pagination">
|
||||
<button
|
||||
[disabled]="selectedPage() === 1"
|
||||
(click)="setPage(selectedPage() - 1)">
|
||||
Zurück
|
||||
</button>
|
||||
<span>Seite {{ selectedPage() }} von {{ pageCount() }}</span>
|
||||
<button
|
||||
[disabled]="selectedPage() === pageCount()"
|
||||
(click)="setPage(selectedPage() + 1)">
|
||||
Weiter
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
<app-query-param-paginator
|
||||
[total]="filteredMatches().length"
|
||||
queryParamPageKey="page"
|
||||
queryParamSizeKey="size"
|
||||
[pageSizeOptions]="[10, 25, 50]"
|
||||
(handlePageChange)="onPatentPageChange($event)" />
|
||||
</div>
|
||||
|
||||
@if (selectedMatch(); as match) {
|
||||
<div class="patent-detail">
|
||||
<h3>{{ match.patent.title ?? match.patent.patent_id }}</h3>
|
||||
<div class="detail-stats">
|
||||
<div class="stat">
|
||||
<span class="stat-label">Match-Score</span>
|
||||
<span class="stat-value">{{
|
||||
formatScore(match.match_score)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat-label">Gematchte Keywords</span>
|
||||
<span class="stat-value">{{
|
||||
formatMatchList(match.matched_keywords)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat-label">Gematchte IPC/CPC</span>
|
||||
<span class="stat-value">{{
|
||||
formatMatchList(match.matched_ipc_symbols)
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<span class="stat-label">Quelle</span>
|
||||
<span class="stat-value">
|
||||
@@ -123,6 +123,10 @@
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (getAbstractPreview(match.patent.abstract); as abstractPreview) {
|
||||
<p class="patent-detail-preview">{{ abstractPreview }}</p>
|
||||
}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="patent-detail-action"
|
||||
@@ -132,40 +136,33 @@
|
||||
>
|
||||
<mat-icon aria-hidden="true">chevron_right</mat-icon>
|
||||
</button>
|
||||
<p class="patent-detail-hint">
|
||||
Abstract, Erfinder, Anmelder und IPC/CPC-Klassifikation
|
||||
</p>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="patent-detail overview">
|
||||
<p class="overview-title">Patentübersicht</p>
|
||||
<p class="overview-subtitle">Patente mit passenden Keywords.</p>
|
||||
<div class="overview-stats">
|
||||
<div class="overview-stat overview-stat--total">
|
||||
<span class="overview-value">{{ matches().length }}</span>
|
||||
<span class="overview-label">Patente</span>
|
||||
</div>
|
||||
<div class="overview-stat overview-stat--epo">
|
||||
<span class="overview-value">{{ getEpoCount() }}</span>
|
||||
<span class="overview-label">EPO</span>
|
||||
</div>
|
||||
<div class="overview-stat overview-stat--uspto">
|
||||
<span class="overview-value">{{ getUsptoCount() }}</span>
|
||||
<span class="overview-label">USPTO</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="overview-hint">
|
||||
Wähle links ein Patent aus, um Details zu sehen.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<ng-template #patentsHeader>
|
||||
<div class="patents-header">
|
||||
<h2 class="section-title">Passende Patente</h2>
|
||||
<div class="patents-header-actions">
|
||||
@if (matches().length > 0) {
|
||||
<label class="sort-control">
|
||||
<span>Filter nach Quelle:</span>
|
||||
<select
|
||||
[value]="activeFilter()"
|
||||
(change)="setFilter($any($event.target).value)">
|
||||
<option value="all">Alle</option>
|
||||
<option value="EPO">EPO</option>
|
||||
<option value="USPTO">USPTO</option>
|
||||
</select>
|
||||
</label>
|
||||
}
|
||||
|
||||
@if (showReload()) {
|
||||
<button
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
class="reload-btn"
|
||||
[disabled]="reloadDisabled()"
|
||||
(click)="onReload()">
|
||||
<mat-icon>refresh</mat-icon>
|
||||
Neu laden
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
+231
-35
@@ -25,24 +25,25 @@
|
||||
background: var(--sg-card-bg);
|
||||
border: 1px solid var(--sg-border);
|
||||
box-shadow: var(--sg-shadow-sm);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.patents-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 16px;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.patents-header-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
margin-left: auto;
|
||||
app-query-param-paginator {
|
||||
display: block;
|
||||
margin-top: 14px;
|
||||
}
|
||||
|
||||
.patents-toolbar-field {
|
||||
width: fit-content;
|
||||
min-width: 180px;
|
||||
}
|
||||
|
||||
.reload-btn {
|
||||
@@ -77,10 +78,66 @@
|
||||
|
||||
.patents-list {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
.patents-list-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 18px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
tr {
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s ease;
|
||||
|
||||
&:hover td {
|
||||
background: rgba(16, 26, 61, 0.04);
|
||||
}
|
||||
|
||||
&.selected td {
|
||||
background: var(--sg-primary-soft);
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
color: var(--sg-text);
|
||||
font-size: 13px;
|
||||
transition: background-color 0.15s ease;
|
||||
}
|
||||
|
||||
.patent-title {
|
||||
color: var(--sg-text);
|
||||
font-weight: 600;
|
||||
max-width: 400px;
|
||||
white-space: normal;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.patent-people {
|
||||
max-width: 220px;
|
||||
color: var(--sg-text-muted);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
th {
|
||||
@@ -114,42 +171,161 @@
|
||||
}
|
||||
|
||||
.source-badge {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 3px 10px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
font-size: 0.75rem;
|
||||
font-weight: 700;
|
||||
|
||||
&--epo {
|
||||
background: var(--sg-primary-soft);
|
||||
color: var(--sg-blue-highlight);
|
||||
background: #effaf3;
|
||||
color: #24834f;
|
||||
border: 1px solid #bdebcf;
|
||||
}
|
||||
|
||||
&--uspto {
|
||||
background: var(--sg-success-soft);
|
||||
color: var(--sg-success);
|
||||
background: #f0f6ff;
|
||||
color: #0b63ce;
|
||||
border: 1px solid #bdd4ff;
|
||||
}
|
||||
}
|
||||
|
||||
.pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.patent-detail {
|
||||
flex: 0 0 320px;
|
||||
padding: 16px;
|
||||
border-radius: 12px;
|
||||
background: var(--sg-surface-muted);
|
||||
border: 1px solid var(--sg-border);
|
||||
width: 440px;
|
||||
padding: 24px;
|
||||
background: var(--sg-surface);
|
||||
box-shadow: var(--sg-shadow-sm);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
|
||||
&.overview {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
|
||||
.overview-title {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: var(--sg-text);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.overview-subtitle {
|
||||
font-size: 13px;
|
||||
color: var(--sg-text-muted);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.overview-stats {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
gap: 10px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.overview-stat {
|
||||
background: var(--sg-surface);
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
padding: 12px 8px;
|
||||
text-align: center;
|
||||
|
||||
.overview-value {
|
||||
display: block;
|
||||
font-size: 22px;
|
||||
font-weight: 700;
|
||||
color: var(--sg-text);
|
||||
}
|
||||
|
||||
.overview-label {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
color: var(--sg-text-muted);
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
&--total {
|
||||
.overview-value,
|
||||
.overview-label {
|
||||
color: #7255d9;
|
||||
}
|
||||
}
|
||||
|
||||
&--epo {
|
||||
.overview-value,
|
||||
.overview-label {
|
||||
color: #24834f;
|
||||
}
|
||||
}
|
||||
|
||||
&--uspto {
|
||||
.overview-value,
|
||||
.overview-label {
|
||||
color: #0b63ce;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.overview-hint {
|
||||
font-size: 12px;
|
||||
color: var(--sg-text-muted);
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 0 0 16px 0;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: var(--sg-text);
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
.detail-stats {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 10px;
|
||||
margin: 12px 0;
|
||||
|
||||
.stat {
|
||||
background: var(--sg-surface);
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
padding: 10px;
|
||||
text-align: center;
|
||||
|
||||
.stat-label {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
color: var(--sg-text-muted);
|
||||
margin-bottom: 4px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
display: block;
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
color: var(--sg-text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.patent-detail-preview {
|
||||
margin: 14px 0 0;
|
||||
font-size: 13px;
|
||||
line-height: 1.55;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.match-score {
|
||||
@@ -174,6 +350,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
padding: 10px 12px;
|
||||
@@ -181,26 +358,45 @@
|
||||
border-radius: 8px;
|
||||
background: var(--sg-primary);
|
||||
color: var(--sg-card-bg);
|
||||
margin-top: 16px;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid #bdd4ff;
|
||||
border-radius: 10px;
|
||||
background: linear-gradient(180deg, #f8fbff 0%, #eef4ff 100%);
|
||||
color: #0b63ce;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition:
|
||||
border-color 0.15s,
|
||||
background 0.15s,
|
||||
box-shadow 0.15s;
|
||||
|
||||
&:hover {
|
||||
border-color: #0b63ce;
|
||||
background: #f0f6ff;
|
||||
box-shadow: 0 2px 8px rgba(11, 99, 206, 0.12);
|
||||
}
|
||||
|
||||
.material-icons {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.patents-header {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.patents-header-actions {
|
||||
margin-left: 0;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.patent-detail-hint {
|
||||
margin: 8px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
color: #888;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.patents-content {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.patent-detail {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
+96
-47
@@ -1,11 +1,14 @@
|
||||
import { NgTemplateOutlet } from '@angular/common';
|
||||
import { Component, input, output, signal } from '@angular/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { Component, computed, inject, input, output, signal } from '@angular/core';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { Router } from '@angular/router';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { PageEvent } from '@angular/material/paginator';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { PatentEntry } from '../../../api/model/patentEntry';
|
||||
import { KeywordPatentMatch } from '../../../api/model/keywordPatentMatch';
|
||||
import { LoadingComponent } from '../../../shared/ui/loading/loading.component';
|
||||
import { QueryParamPaginatorComponent } from '../../../shared/ui/query-param-paginator/query-param-paginator.component';
|
||||
import {
|
||||
formatPatentDate,
|
||||
getPublicationStageLabel,
|
||||
@@ -13,14 +16,25 @@ import {
|
||||
import { KeywordPatentMappingStatus } from '../../../api';
|
||||
|
||||
type SourceFilter = 'all' | 'EPO' | 'USPTO';
|
||||
type SortMode = 'date' | 'title';
|
||||
|
||||
@Component({
|
||||
selector: 'app-keywords-patents',
|
||||
imports: [NgTemplateOutlet, MatButtonModule, MatIconModule, LoadingComponent],
|
||||
imports: [
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatSelectModule,
|
||||
LoadingComponent,
|
||||
QueryParamPaginatorComponent,
|
||||
],
|
||||
templateUrl: './keywords-patents.component.html',
|
||||
styleUrl: './keywords-patents.component.scss',
|
||||
})
|
||||
export class KeywordsPatentsComponent {
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
private readonly queryParams = toSignal(this.route.queryParams);
|
||||
|
||||
readonly matches = input<KeywordPatentMatch[]>([]);
|
||||
readonly mappingStatus = input<KeywordPatentMappingStatus | null>(null);
|
||||
readonly loading = input(false);
|
||||
@@ -30,54 +44,65 @@ export class KeywordsPatentsComponent {
|
||||
readonly reload = output<void>();
|
||||
|
||||
activeFilter = signal<SourceFilter>('all');
|
||||
sortMode = signal<SortMode>('date');
|
||||
selectedMatch = signal<KeywordPatentMatch | null>(null);
|
||||
selectedPage = signal(1);
|
||||
readonly pageSize = 10;
|
||||
|
||||
constructor(private readonly router: Router) {}
|
||||
readonly pageIndex = computed(() => {
|
||||
const params = this.queryParams();
|
||||
return params?.['page'] ? +params['page'] || 0 : 0;
|
||||
});
|
||||
|
||||
readonly pageSize = computed(() => {
|
||||
const params = this.queryParams();
|
||||
return params?.['size'] ? +params['size'] || 10 : 10;
|
||||
});
|
||||
|
||||
readonly filteredMatches = computed(() => {
|
||||
const filter = this.activeFilter();
|
||||
let items = this.matches();
|
||||
if (filter !== 'all') {
|
||||
items = items.filter((item) => item.patent.source === filter);
|
||||
}
|
||||
return this.sortMatches(items);
|
||||
});
|
||||
|
||||
emptyMessage(): string {
|
||||
switch (this.mappingStatus()) {
|
||||
case 'search_error':
|
||||
return 'Die Patentrecherche ist technisch fehlgeschlagen. Bitte später erneut versuchen.';
|
||||
default:
|
||||
return 'Keine passenden Patente gefunden';
|
||||
return 'Keine passenden Patente gefunden.';
|
||||
}
|
||||
}
|
||||
|
||||
filteredMatches(): KeywordPatentMatch[] {
|
||||
const filter = this.activeFilter();
|
||||
const items = this.matches();
|
||||
if (filter === 'all') {
|
||||
return items;
|
||||
}
|
||||
return items.filter((item) => item.patent.source === filter);
|
||||
}
|
||||
|
||||
pagedMatches(): KeywordPatentMatch[] {
|
||||
const start = (this.selectedPage() - 1) * this.pageSize;
|
||||
return this.filteredMatches().slice(start, start + this.pageSize);
|
||||
}
|
||||
|
||||
pageCount(): number {
|
||||
return Math.max(
|
||||
1,
|
||||
Math.ceil(this.filteredMatches().length / this.pageSize),
|
||||
);
|
||||
}
|
||||
|
||||
hasPagination(): boolean {
|
||||
return this.pageCount() > 1;
|
||||
getPagedMatches(): KeywordPatentMatch[] {
|
||||
const start = this.pageIndex() * this.pageSize();
|
||||
return this.filteredMatches().slice(start, start + this.pageSize());
|
||||
}
|
||||
|
||||
setFilter(filter: SourceFilter): void {
|
||||
this.activeFilter.set(filter);
|
||||
this.selectedPage.set(1);
|
||||
this.selectedMatch.set(null);
|
||||
this.resetPage();
|
||||
}
|
||||
|
||||
setSortMode(sortMode: SortMode): void {
|
||||
this.sortMode.set(sortMode);
|
||||
this.selectedMatch.set(null);
|
||||
this.resetPage();
|
||||
}
|
||||
|
||||
onPatentPageChange(_event: PageEvent): void {
|
||||
this.selectedMatch.set(null);
|
||||
}
|
||||
|
||||
setPage(page: number): void {
|
||||
this.selectedPage.set(Math.min(Math.max(page, 1), this.pageCount()));
|
||||
private resetPage(): void {
|
||||
void this.router.navigate([], {
|
||||
relativeTo: this.route,
|
||||
queryParams: { page: 0 },
|
||||
queryParamsHandling: 'merge',
|
||||
replaceUrl: true,
|
||||
});
|
||||
}
|
||||
|
||||
selectMatch(item: KeywordPatentMatch): void {
|
||||
@@ -90,8 +115,21 @@ export class KeywordsPatentsComponent {
|
||||
void this.router.navigate(['/patent', match.patent.patent_id]);
|
||||
}
|
||||
|
||||
onReload(): void {
|
||||
this.reload.emit();
|
||||
getEpoCount(): number {
|
||||
return this.matches().filter((item) => item.patent.source === 'EPO').length;
|
||||
}
|
||||
|
||||
getUsptoCount(): number {
|
||||
return this.matches().filter((item) => item.patent.source === 'USPTO')
|
||||
.length;
|
||||
}
|
||||
|
||||
getInventorsLabel(patent: PatentEntry): string {
|
||||
return patent.inventors?.length ? patent.inventors.join(', ') : '-';
|
||||
}
|
||||
|
||||
getAssigneesLabel(patent: PatentEntry): string {
|
||||
return patent.assignees?.length ? patent.assignees.join(', ') : '-';
|
||||
}
|
||||
|
||||
formatDate(date: string | null | undefined): string {
|
||||
@@ -102,18 +140,15 @@ export class KeywordsPatentsComponent {
|
||||
return getPublicationStageLabel(patent);
|
||||
}
|
||||
|
||||
formatScore(score: number | null | undefined): string {
|
||||
if (score == null || Number.isNaN(score)) {
|
||||
return '-';
|
||||
getAbstractPreview(abstract: string | null | undefined): string | null {
|
||||
if (!abstract?.trim()) {
|
||||
return null;
|
||||
}
|
||||
return score.toFixed(2);
|
||||
}
|
||||
|
||||
formatMatchList(values: string[] | null | undefined): string {
|
||||
if (!values || values.length === 0) {
|
||||
return '-';
|
||||
const text = abstract.trim();
|
||||
if (text.length <= 160) {
|
||||
return text;
|
||||
}
|
||||
return values.join(', ');
|
||||
return `${text.slice(0, 160).trimEnd()}…`;
|
||||
}
|
||||
|
||||
trackMatch(_index: number, item: KeywordPatentMatch): string {
|
||||
@@ -126,4 +161,18 @@ export class KeywordsPatentsComponent {
|
||||
item.match_score,
|
||||
].join('|');
|
||||
}
|
||||
|
||||
private sortMatches(items: KeywordPatentMatch[]): KeywordPatentMatch[] {
|
||||
const mode = this.sortMode();
|
||||
return [...items].sort((a, b) => {
|
||||
if (mode === 'date') {
|
||||
return (b.patent.publication_date ?? '').localeCompare(
|
||||
a.patent.publication_date ?? '',
|
||||
);
|
||||
}
|
||||
return (a.patent.title ?? '').localeCompare(b.patent.title ?? '', 'de', {
|
||||
sensitivity: 'base',
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,81 +108,3 @@ function sameKeywordSet(a: string[], b: string[]): boolean {
|
||||
const setA = new Set(a.map((keyword) => normalizeKeyword(keyword)));
|
||||
return b.every((keyword) => setA.has(normalizeKeyword(keyword)));
|
||||
}
|
||||
|
||||
export interface PatentScoreWeights {
|
||||
ipc: number;
|
||||
topic: number;
|
||||
text: number;
|
||||
}
|
||||
|
||||
export const DEFAULT_PATENT_SCORE_WEIGHTS: PatentScoreWeights = {
|
||||
ipc: 0.6,
|
||||
topic: 0.25,
|
||||
text: 0.15,
|
||||
};
|
||||
|
||||
export function normalizePatentScoreWeights(
|
||||
raw: Record<string, number>,
|
||||
): PatentScoreWeights {
|
||||
const ipc = raw['ipc'] ?? DEFAULT_PATENT_SCORE_WEIGHTS.ipc;
|
||||
const topic = raw['topic'] ?? DEFAULT_PATENT_SCORE_WEIGHTS.topic;
|
||||
const text = raw['text'] ?? DEFAULT_PATENT_SCORE_WEIGHTS.text;
|
||||
const sum = ipc + topic + text;
|
||||
if (sum <= 0) {
|
||||
return { ...DEFAULT_PATENT_SCORE_WEIGHTS };
|
||||
}
|
||||
return { ipc: ipc / sum, topic: topic / sum, text: text / sum };
|
||||
}
|
||||
|
||||
export function computePatentMatchScore(
|
||||
match: Pick<KeywordPatentMatch, 'ipc_score' | 'topic_score' | 'text_score'>,
|
||||
weights: PatentScoreWeights,
|
||||
): number {
|
||||
return (
|
||||
Math.round(
|
||||
(weights.ipc * match.ipc_score +
|
||||
weights.topic * match.topic_score +
|
||||
weights.text * match.text_score) *
|
||||
10000,
|
||||
) / 10000
|
||||
);
|
||||
}
|
||||
|
||||
export function applyPatentScoreWeights(
|
||||
matches: KeywordPatentMatch[],
|
||||
weights: PatentScoreWeights,
|
||||
): KeywordPatentMatch[] {
|
||||
return [...matches]
|
||||
.map((match) => ({
|
||||
...match,
|
||||
match_score: computePatentMatchScore(match, weights),
|
||||
}))
|
||||
.sort((a, b) => {
|
||||
const scoreDiff = b.match_score - a.match_score;
|
||||
if (scoreDiff !== 0) {
|
||||
return scoreDiff;
|
||||
}
|
||||
|
||||
const dateA = a.patent.publication_date ?? '';
|
||||
const dateB = b.patent.publication_date ?? '';
|
||||
if (dateA !== dateB) {
|
||||
return dateB.localeCompare(dateA);
|
||||
}
|
||||
|
||||
return a.patent.patent_id.localeCompare(b.patent.patent_id);
|
||||
});
|
||||
}
|
||||
|
||||
function hasPatentComponentScores(match: KeywordPatentMatch): boolean {
|
||||
return (
|
||||
typeof match.ipc_score === 'number' &&
|
||||
typeof match.topic_score === 'number' &&
|
||||
typeof match.text_score === 'number'
|
||||
);
|
||||
}
|
||||
|
||||
export function canReweightPatentMatches(
|
||||
matches: KeywordPatentMatch[],
|
||||
): boolean {
|
||||
return matches.length > 0 && matches.every(hasPatentComponentScores);
|
||||
}
|
||||
|
||||
-20
@@ -1,24 +1,4 @@
|
||||
<div class="result-layout">
|
||||
<mat-card class="weights-card">
|
||||
<mat-card-content>
|
||||
<app-weights-sliders
|
||||
[options]="weightOptions"
|
||||
[initialWeights]="defaultWeights"
|
||||
title="Patenten-Gewichtung"
|
||||
description="Steuert die Gewichtung von IPC/CPC-Match, OpenAlex-Topic und Text-Match für den Gesamt-Score."
|
||||
resetLabel="Standard"
|
||||
applyLabel="Neu gewichten"
|
||||
normalizedTitle="Normalisiert"
|
||||
queryParamPrefix="patentW_"
|
||||
[persistInQueryParams]="true"
|
||||
[showApplyButton]="true"
|
||||
[showResetButton]="true"
|
||||
[showNormalizedPreview]="true"
|
||||
(weightsChange)="onWeightsChange($event)"
|
||||
(applyWeights)="onApplyWeights($event)" />
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<div class="results-card">
|
||||
<app-keywords-patents
|
||||
[matches]="patentMatches()"
|
||||
|
||||
+1
-13
@@ -1,20 +1,8 @@
|
||||
/* ============================================================
|
||||
RESULT LAYOUT
|
||||
============================================================ */
|
||||
.result-layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
|
||||
grid-template-areas: 'summary results';
|
||||
gap: 0.75rem;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.weights-card {
|
||||
grid-area: summary;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.results-card {
|
||||
grid-area: results;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
|
||||
+3
-96
@@ -1,26 +1,12 @@
|
||||
import { Component, inject, OnInit, signal } from '@angular/core';
|
||||
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
||||
import { KeywordsService } from '../../../../api/api/keywords.service';
|
||||
import { KeywordPatentMatch } from '../../../../api/model/keywordPatentMatch';
|
||||
import { PatentsByKeywordsResponse } from '../../../../api/model/patentsByKeywordsResponse';
|
||||
import {
|
||||
WeightMap,
|
||||
WeightSliderOption,
|
||||
WeightsSlidersComponent,
|
||||
WeightsSlidersValue,
|
||||
} from '../../../../shared/ui/weights-sliders/weights-sliders.component';
|
||||
import { KeywordsPatentsComponent } from '../../keywords-patents/keywords-patents.component';
|
||||
import {
|
||||
applyPatentScoreWeights,
|
||||
buildPatentSearchItemsFromPayload,
|
||||
canReweightPatentMatches,
|
||||
clearPatentsCache,
|
||||
DEFAULT_PATENT_SCORE_WEIGHTS,
|
||||
normalizePatentScoreWeights,
|
||||
readPatentsCache,
|
||||
writePatentsCache,
|
||||
} from '../../patent-search.utils';
|
||||
@@ -29,13 +15,7 @@ import { KeywordPatentMappingStatus } from '../../../../api';
|
||||
|
||||
@Component({
|
||||
selector: 'app-patents-results',
|
||||
imports: [
|
||||
MatCardModule,
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
WeightsSlidersComponent,
|
||||
KeywordsPatentsComponent,
|
||||
],
|
||||
imports: [KeywordsPatentsComponent],
|
||||
templateUrl: './patents-results.component.html',
|
||||
styleUrl: './patents-results.component.scss',
|
||||
})
|
||||
@@ -43,53 +23,11 @@ export class KeywordsToPatentsResultsComponent implements OnInit {
|
||||
protected readonly state = inject(SearchResultsStateService);
|
||||
private readonly keywordsService = inject(KeywordsService);
|
||||
|
||||
readonly defaultWeights: WeightMap = { ...DEFAULT_PATENT_SCORE_WEIGHTS };
|
||||
|
||||
readonly weightOptions: WeightSliderOption[] = [
|
||||
{
|
||||
key: 'ipc',
|
||||
label: 'IPC/CPC-Match',
|
||||
icon: 'category',
|
||||
description:
|
||||
'Gewichtet die Übereinstimmung der Patent-Klassifikation (IPC/CPC) mit den Keywords.',
|
||||
defaultValue: DEFAULT_PATENT_SCORE_WEIGHTS.ipc,
|
||||
queryParamName: 'wIpc',
|
||||
},
|
||||
{
|
||||
key: 'topic',
|
||||
label: 'OpenAlex-Topic',
|
||||
icon: 'hub',
|
||||
description:
|
||||
'Gewichtet die thematische Übereinstimmung über OpenAlex-Topics und Fachgebiete.',
|
||||
defaultValue: DEFAULT_PATENT_SCORE_WEIGHTS.topic,
|
||||
queryParamName: 'wTopic',
|
||||
},
|
||||
{
|
||||
key: 'text',
|
||||
label: 'Text-Match',
|
||||
icon: 'article',
|
||||
description:
|
||||
'Gewichtet Treffer der Keywords im Patenttitel und in der Zusammenfassung.',
|
||||
defaultValue: DEFAULT_PATENT_SCORE_WEIGHTS.text,
|
||||
queryParamName: 'wText',
|
||||
},
|
||||
];
|
||||
|
||||
readonly currentWeights = signal<WeightsSlidersValue>({
|
||||
raw: this.defaultWeights,
|
||||
normalized: { ...DEFAULT_PATENT_SCORE_WEIGHTS },
|
||||
rawSum: 1,
|
||||
normalizedSum: 1,
|
||||
valid: true,
|
||||
});
|
||||
|
||||
readonly patentMatches = signal<KeywordPatentMatch[]>([]);
|
||||
readonly mappingStatus = signal<KeywordPatentMappingStatus | null>(null);
|
||||
readonly loadingPatents = signal(false);
|
||||
readonly patentsError = signal(false);
|
||||
|
||||
private readonly patentMatchesBase = signal<KeywordPatentMatch[]>([]);
|
||||
|
||||
ngOnInit(): void {
|
||||
const cached = readPatentsCache(this.state.keywords());
|
||||
if (cached) {
|
||||
@@ -100,19 +38,6 @@ export class KeywordsToPatentsResultsComponent implements OnInit {
|
||||
this.loadMatchingPatents();
|
||||
}
|
||||
|
||||
onWeightsChange(value: WeightsSlidersValue): void {
|
||||
this.currentWeights.set(value);
|
||||
}
|
||||
|
||||
onApplyWeights(value: WeightsSlidersValue): void {
|
||||
this.currentWeights.set(value);
|
||||
if (!canReweightPatentMatches(this.patentMatchesBase())) {
|
||||
this.reloadPatents();
|
||||
return;
|
||||
}
|
||||
this.updateDisplayedMatches();
|
||||
}
|
||||
|
||||
reloadPatents(): void {
|
||||
clearPatentsCache();
|
||||
this.loadMatchingPatents();
|
||||
@@ -149,26 +74,8 @@ export class KeywordsToPatentsResultsComponent implements OnInit {
|
||||
matches: KeywordPatentMatch[],
|
||||
mappingStatus: KeywordPatentMappingStatus | null = null,
|
||||
): void {
|
||||
this.patentMatchesBase.set(matches);
|
||||
this.patentMatches.set(matches);
|
||||
this.mappingStatus.set(mappingStatus);
|
||||
this.updateDisplayedMatches();
|
||||
writePatentsCache(
|
||||
this.state.keywords(),
|
||||
this.patentMatchesBase(),
|
||||
mappingStatus,
|
||||
);
|
||||
}
|
||||
|
||||
private updateDisplayedMatches(): void {
|
||||
const base = this.patentMatchesBase();
|
||||
if (!canReweightPatentMatches(base)) {
|
||||
this.patentMatches.set(base);
|
||||
return;
|
||||
}
|
||||
|
||||
const weights = normalizePatentScoreWeights(
|
||||
this.currentWeights().normalized,
|
||||
);
|
||||
this.patentMatches.set(applyPatentScoreWeights(base, weights));
|
||||
writePatentsCache(this.state.keywords(), matches, mappingStatus);
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -9,6 +9,11 @@
|
||||
<a
|
||||
matTabLink
|
||||
[routerLink]="[route.path]"
|
||||
[queryParams]="{
|
||||
authorId: null,
|
||||
institutionId: null,
|
||||
agency: null,
|
||||
}"
|
||||
queryParamsHandling="merge"
|
||||
routerLinkActive
|
||||
#rla="routerLinkActive"
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
</button>
|
||||
|
||||
@if (loading) {
|
||||
<div class="state">
|
||||
<mat-spinner diameter="42"></mat-spinner>
|
||||
<p>Nachricht wird geladen...</p>
|
||||
</div>
|
||||
<app-loading
|
||||
text="Nachricht wird geladen..."
|
||||
icon="newspaper"
|
||||
[size]="60"
|
||||
[diameter]="60" />
|
||||
} @else if (notFound || !article) {
|
||||
<div class="state error-state">
|
||||
<mat-icon>search_off</mat-icon>
|
||||
|
||||
@@ -11,13 +11,13 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
||||
|
||||
import { WorksService } from '../../api';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
|
||||
interface MentionedPerson {
|
||||
name: string;
|
||||
@@ -52,9 +52,9 @@ interface NewsArticleDetail {
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatTooltipModule,
|
||||
RouterLink,
|
||||
LoadingComponent,
|
||||
],
|
||||
templateUrl: './news-detail.component.html',
|
||||
styleUrl: './news-detail.component.scss',
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
|
||||
<ng-template #additionalFiltersTmp>
|
||||
<div class="additional-filters">
|
||||
<mat-form-field appearance="outline" class="relevance-field">
|
||||
<mat-form-field
|
||||
appearance="outline"
|
||||
subscriptSizing="dynamic"
|
||||
class="relevance-field">
|
||||
<mat-select
|
||||
[formControl]="relevanceFilter"
|
||||
placeholder="Relevanz"
|
||||
@@ -28,28 +31,14 @@
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<div class="year-field">
|
||||
<div class="year-field__head">
|
||||
<span class="year-field__label">Datum</span>
|
||||
<span class="year-field__range">
|
||||
{{ yearFrom.value }} – {{ yearTo.value }}
|
||||
</span>
|
||||
</div>
|
||||
<mat-slider [min]="minYear" [max]="maxYear" step="1" discrete>
|
||||
<input matSliderStartThumb [formControl]="yearFrom" />
|
||||
<input matSliderEndThumb [formControl]="yearTo" />
|
||||
</mat-slider>
|
||||
</div>
|
||||
|
||||
<button
|
||||
class="reset-filter-btn"
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
(click)="resetFilters()"
|
||||
aria-label="Filter zurücksetzen">
|
||||
<mat-icon>filter_alt_off</mat-icon>
|
||||
<span>Zurücksetzen</span>
|
||||
</button>
|
||||
<app-year-range-slider
|
||||
class="year-field"
|
||||
[minYear]="minYear"
|
||||
[maxYear]="maxYear"
|
||||
[startYear]="yearFrom.value"
|
||||
[endYear]="yearTo.value"
|
||||
(startYearChange)="yearFrom.setValue($event)"
|
||||
(endYearChange)="yearTo.setValue($event)" />
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
gap: 40px;
|
||||
padding: 0 1rem 1rem;
|
||||
}
|
||||
|
||||
@@ -57,54 +57,7 @@
|
||||
}
|
||||
|
||||
.year-field {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
min-width: 220px;
|
||||
padding: 0 6px;
|
||||
margin-top: -20px;
|
||||
}
|
||||
|
||||
.year-field__head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
font-size: 12px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.year-field__label {
|
||||
color: var(--sg-text-muted);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.year-field__range {
|
||||
color: var(--sg-text);
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.year-field mat-slider {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.reset-filter-btn {
|
||||
min-width: 132px;
|
||||
height: 42px;
|
||||
padding: 0 14px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
color: var(--sg-text);
|
||||
background: var(--sg-surface);
|
||||
|
||||
mat-icon {
|
||||
margin-right: 6px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: 20px;
|
||||
}
|
||||
min-width: 280px;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
|
||||
@@ -13,9 +13,6 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { debounceTime, merge } from 'rxjs';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { MatSliderModule } from '@angular/material/slider';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
|
||||
import { WorksService } from '../../api';
|
||||
import {
|
||||
@@ -28,6 +25,7 @@ import {
|
||||
NEWS_MIN_YEAR,
|
||||
} from '../../shared/ui/news-card/news-card.component';
|
||||
import { SelectorOption } from '../../shared/ui/query-param-selector/query-param-selector.component';
|
||||
import { YearRangeSliderComponent } from '../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
|
||||
interface NewsArticle extends NewsArticleBase {
|
||||
author?: string | null;
|
||||
@@ -49,11 +47,9 @@ type SortOrder = 'desc' | 'asc';
|
||||
ReactiveFormsModule,
|
||||
MatFormFieldModule,
|
||||
MatSelectModule,
|
||||
MatSliderModule,
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
CardSearchComponent,
|
||||
NewsCardComponent,
|
||||
YearRangeSliderComponent,
|
||||
],
|
||||
templateUrl: './news.component.html',
|
||||
styleUrl: './news.component.scss',
|
||||
@@ -138,12 +134,6 @@ export class NewsComponent implements OnInit {
|
||||
.subscribe(() => this.applyFilters());
|
||||
}
|
||||
|
||||
resetFilters(): void {
|
||||
this.relevanceFilter.setValue([]);
|
||||
this.yearFrom.setValue(this.minYear);
|
||||
this.yearTo.setValue(this.maxYear);
|
||||
}
|
||||
|
||||
private applyFilters(): void {
|
||||
const relevance =
|
||||
this.relevanceFilter.value.length > 0
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
</button>
|
||||
|
||||
@if (loading) {
|
||||
<div class="state">
|
||||
<mat-spinner diameter="42"></mat-spinner>
|
||||
<p>Patent wird geladen...</p>
|
||||
</div>
|
||||
<app-loading
|
||||
text="Patent wird geladen..."
|
||||
icon="workspace_premium"
|
||||
[size]="60"
|
||||
[diameter]="60" />
|
||||
} @else if (notFound || !patent) {
|
||||
<div class="state error-state">
|
||||
<mat-icon>search_off</mat-icon>
|
||||
|
||||
@@ -3,7 +3,6 @@ import { Component, DestroyRef, OnInit, inject } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { ActivatedRoute, RouterLink } from '@angular/router';
|
||||
import { finalize } from 'rxjs';
|
||||
|
||||
@@ -15,6 +14,7 @@ import {
|
||||
classificationSectionColor,
|
||||
topicHierarchyColor,
|
||||
} from '../../resolvers/utils/topic-colors';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
import {
|
||||
ClassificationCard,
|
||||
ClassificationSystem,
|
||||
@@ -32,9 +32,9 @@ import {
|
||||
imports: [
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
RouterLink,
|
||||
TopicChipComponent,
|
||||
LoadingComponent,
|
||||
],
|
||||
templateUrl: './patent-detail.component.html',
|
||||
styleUrl: './patent-detail.component.scss',
|
||||
|
||||
@@ -26,54 +26,14 @@
|
||||
<mat-chip-option value="USPTO">USPTO</mat-chip-option>
|
||||
</mat-chip-listbox>
|
||||
|
||||
<div class="year-filter">
|
||||
<div class="year-filter-top">
|
||||
<span class="year-filter-label">Zeitraum</span>
|
||||
|
||||
<span class="year-filter-values">
|
||||
{{ selectedStartYear }} bis {{ selectedEndYear }}
|
||||
</span>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="reset-range-button"
|
||||
[disabled]="!canResetYearRange"
|
||||
(click)="resetYearRange()">
|
||||
Zurücksetzen
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="year-range-slider"
|
||||
[style.--range-start]="rangeStartPercent"
|
||||
[style.--range-end]="rangeEndPercent">
|
||||
<div class="range-track"></div>
|
||||
<input
|
||||
class="range-input range-input-start"
|
||||
type="range"
|
||||
[min]="minYear"
|
||||
[max]="maxYear"
|
||||
[value]="selectedStartYear"
|
||||
[style.z-index]="selectedStartYear >= selectedEndYear - 5 ? 4 : 2"
|
||||
(input)="onStartYearDrag($event)"
|
||||
(change)="onStartYearInput($event)"
|
||||
aria-label="Startjahr" />
|
||||
<input
|
||||
class="range-input range-input-end"
|
||||
type="range"
|
||||
[min]="minYear"
|
||||
[max]="maxYear"
|
||||
[value]="selectedEndYear"
|
||||
(input)="onEndYearDrag($event)"
|
||||
(change)="onEndYearInput($event)"
|
||||
aria-label="Endjahr" />
|
||||
</div>
|
||||
|
||||
<div class="year-filter-bounds">
|
||||
<span>{{ minYear }}</span>
|
||||
<span>{{ maxYear }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<app-year-range-slider
|
||||
class="patent-year-filter"
|
||||
[minYear]="minYear"
|
||||
[maxYear]="maxYear"
|
||||
[(startYear)]="selectedStartYear"
|
||||
[(endYear)]="selectedEndYear"
|
||||
(startYearChange)="onYearRangeChange()"
|
||||
(endYearChange)="onYearRangeChange()" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -32,134 +32,8 @@ h1 {
|
||||
border-radius: var(--sg-radius-sm);
|
||||
}
|
||||
|
||||
.year-filter {
|
||||
.patent-year-filter {
|
||||
width: min(285px, 100%);
|
||||
padding: 5px 10px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 10px;
|
||||
background: var(--sg-surface-muted);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.year-filter-top {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.year-filter-label {
|
||||
color: var(--sg-text);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.reset-range-button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--sg-blue-highlight);
|
||||
font-size: 11px;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
font-family: inherit;
|
||||
|
||||
&:disabled {
|
||||
color: var(--sg-text-soft);
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
|
||||
.year-filter-values {
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.year-filter-bounds {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 0;
|
||||
color: var(--sg-text-soft);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.year-range-slider {
|
||||
--range-start: 0%;
|
||||
--range-end: 100%;
|
||||
--accent: var(--sg-blue-highlight);
|
||||
|
||||
position: relative;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.range-track {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 5px;
|
||||
transform: translateY(-50%);
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
var(--sg-border) 0%,
|
||||
var(--sg-border) var(--range-start),
|
||||
var(--accent) var(--range-start),
|
||||
var(--accent) var(--range-end),
|
||||
var(--sg-border) var(--range-end),
|
||||
var(--sg-border) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.range-input {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 22px;
|
||||
margin: 0;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
pointer-events: none;
|
||||
|
||||
&::-webkit-slider-runnable-track,
|
||||
&::-moz-range-track {
|
||||
height: 5px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
&::-webkit-slider-thumb {
|
||||
appearance: none;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
margin-top: -5px;
|
||||
border: 2px solid var(--sg-surface);
|
||||
border-radius: 50%;
|
||||
background: var(--sg-blue-highlight);
|
||||
box-shadow: var(--sg-shadow-sm);
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
&::-moz-range-thumb {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border: 2px solid var(--sg-surface);
|
||||
border-radius: 50%;
|
||||
background: var(--sg-blue-highlight);
|
||||
box-shadow: var(--sg-shadow-sm);
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.range-input-start {
|
||||
z-index: 2;
|
||||
}
|
||||
.range-input-end {
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.state-message {
|
||||
|
||||
@@ -17,6 +17,7 @@ import { IpcClassification } from '../../api';
|
||||
import { OpenAlexTopicTag } from '../../api/model/openAlexTopicTag';
|
||||
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
import { YearRangeSliderComponent } from '../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
import {
|
||||
classificationSectionColor,
|
||||
topicHierarchyColor,
|
||||
@@ -54,6 +55,7 @@ const MIN_YEAR = 1978;
|
||||
MatDividerModule,
|
||||
TopicChipComponent,
|
||||
LoadingComponent,
|
||||
YearRangeSliderComponent,
|
||||
],
|
||||
templateUrl: './patents.component.html',
|
||||
styleUrl: './patents.component.scss',
|
||||
@@ -117,69 +119,7 @@ export class PatentsComponent implements OnInit {
|
||||
this.loadPatents();
|
||||
}
|
||||
|
||||
get rangeStartPercent(): string {
|
||||
const total = this.maxYear - this.minYear;
|
||||
return `${((this.selectedStartYear - this.minYear) / total) * 100}%`;
|
||||
}
|
||||
|
||||
get rangeEndPercent(): string {
|
||||
const total = this.maxYear - this.minYear;
|
||||
return `${((this.selectedEndYear - this.minYear) / total) * 100}%`;
|
||||
}
|
||||
|
||||
get canResetYearRange(): boolean {
|
||||
return (
|
||||
this.selectedStartYear !== this.minYear ||
|
||||
this.selectedEndYear !== this.maxYear
|
||||
);
|
||||
}
|
||||
|
||||
// Fired continuously while dragging: only updates the displayed value/handle
|
||||
// position, no HTTP request yet.
|
||||
onStartYearDrag(event: Event): void {
|
||||
const input = event.target as HTMLInputElement;
|
||||
this.selectedStartYear = Math.min(
|
||||
parseInt(input.value, 10),
|
||||
this.selectedEndYear,
|
||||
);
|
||||
}
|
||||
|
||||
onEndYearDrag(event: Event): void {
|
||||
const input = event.target as HTMLInputElement;
|
||||
this.selectedEndYear = Math.max(
|
||||
parseInt(input.value, 10),
|
||||
this.selectedStartYear,
|
||||
);
|
||||
}
|
||||
|
||||
// Fired once on release: commits the value and triggers the search request.
|
||||
onStartYearInput(event: Event): void {
|
||||
const input = event.target as HTMLInputElement;
|
||||
this.selectedStartYear = Math.min(
|
||||
parseInt(input.value, 10),
|
||||
this.selectedEndYear,
|
||||
);
|
||||
input.value = String(this.selectedStartYear);
|
||||
this.page = 0;
|
||||
this.loadPatents();
|
||||
this.updateQueryParams();
|
||||
}
|
||||
|
||||
onEndYearInput(event: Event): void {
|
||||
const input = event.target as HTMLInputElement;
|
||||
this.selectedEndYear = Math.max(
|
||||
parseInt(input.value, 10),
|
||||
this.selectedStartYear,
|
||||
);
|
||||
input.value = String(this.selectedEndYear);
|
||||
this.page = 0;
|
||||
this.loadPatents();
|
||||
this.updateQueryParams();
|
||||
}
|
||||
|
||||
resetYearRange(): void {
|
||||
this.selectedStartYear = this.minYear;
|
||||
this.selectedEndYear = this.maxYear;
|
||||
onYearRangeChange(): void {
|
||||
this.page = 0;
|
||||
this.loadPatents();
|
||||
this.updateQueryParams();
|
||||
|
||||
@@ -40,19 +40,10 @@
|
||||
{{ hIndexString() }}
|
||||
</p>
|
||||
@if (!loading()) {
|
||||
@if (careerStage(); as careerStage) {
|
||||
<div [skText]="loading()" class="career-stage-line">
|
||||
<span class="career-stage-label">Career Stage:</span>
|
||||
<span
|
||||
class="career-stage-chip"
|
||||
[matTooltip]="getCareerStageTooltip(careerStage)"
|
||||
matTooltipPosition="right"
|
||||
matTooltipClass="career-stage-tooltip"
|
||||
[matTooltipShowDelay]="250">
|
||||
{{ careerStage }}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
<app-career-stage-chip
|
||||
[careerStage]="person().career_metrics?.career_stage"
|
||||
[activeYears]="person().career_metrics?.active_years"
|
||||
size="sm" />
|
||||
}
|
||||
</div>
|
||||
</a>
|
||||
@@ -86,12 +77,11 @@
|
||||
>{{ inst.display_name ?? '' }}</span
|
||||
>
|
||||
@if (inst.country_code && !loading()) {
|
||||
<img
|
||||
alt=""
|
||||
class="flag-img"
|
||||
[src]="`https://flagcdn.io/${inst.country_code.toLowerCase()}.svg`"
|
||||
height="10"
|
||||
style="margin-left: 6px; vertical-align: middle" />
|
||||
<app-country-flag
|
||||
[countryCode]="inst.country_code"
|
||||
[height]="10"
|
||||
[bordered]="false"
|
||||
style="margin-left: 6px" />
|
||||
<span
|
||||
class="country-code"
|
||||
style="font-size: 9px; margin-left: 2px; vertical-align: middle"
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.flag-img {
|
||||
app-country-flag {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
@@ -242,11 +242,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
.flag-img {
|
||||
border: 1px solid;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.person-id {
|
||||
margin: 2px 0 0;
|
||||
font-size: 10px;
|
||||
@@ -269,39 +264,6 @@
|
||||
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;
|
||||
|
||||
@@ -6,6 +6,8 @@ import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { CustomAuthor, DehydratedInstitution, WorkTopic } from '../../api';
|
||||
import { SkTextDirective } from '../../custom-directives/sk-text.directive';
|
||||
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { CountryFlagComponent } from '../../shared/ui/country-flag/country-flag.component';
|
||||
import { CareerStageChipComponent } from '../../shared/ui/career-stage-chip/career-stage-chip.component';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
|
||||
@Component({
|
||||
@@ -18,6 +20,8 @@ import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
SkTextDirective,
|
||||
MatTooltipModule,
|
||||
TopicChipComponent,
|
||||
CountryFlagComponent,
|
||||
CareerStageChipComponent,
|
||||
],
|
||||
templateUrl: './person-card.component.html',
|
||||
styleUrl: './person-card.component.scss',
|
||||
@@ -126,16 +130,6 @@ export class PersonCardComponent {
|
||||
return '';
|
||||
});
|
||||
|
||||
careerStage = computed<string | null>(() => {
|
||||
const stage = this.person().career_metrics?.career_stage;
|
||||
|
||||
if (!stage || stage === 'unknown') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return stage;
|
||||
});
|
||||
|
||||
getRatingClass(rating: string | null | undefined): string {
|
||||
const r = (rating || '').toLowerCase();
|
||||
if (r === 'sehr geeignet') return 'very-suitable';
|
||||
@@ -172,23 +166,6 @@ export class PersonCardComponent {
|
||||
return id.replace('https://openalex.org/', '').trim().toUpperCase();
|
||||
}
|
||||
|
||||
getCareerStageTooltip(careerStage: string): string {
|
||||
const activeYears = this.person().career_metrics?.active_years ?? '-';
|
||||
|
||||
return [
|
||||
`Aktuell: ${careerStage.replace(' Researcher', '')}`,
|
||||
`Aktive Publikationsjahre: ${activeYears}`,
|
||||
'',
|
||||
'Einteilung:',
|
||||
'Early: 1-4 aktive Publikationsjahre',
|
||||
'Emerging: 5-9 aktive Publikationsjahre',
|
||||
'Established: 10-14 aktive Publikationsjahre',
|
||||
'Senior: ab 15 aktiven Publikationsjahren',
|
||||
'',
|
||||
'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.',
|
||||
].join('\n');
|
||||
}
|
||||
|
||||
toggleBookmark(): void {
|
||||
this.bookmarkToggle.emit(this.person());
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,8 +1,9 @@
|
||||
@if (loading) {
|
||||
<div class="state state-loading" aria-live="polite">
|
||||
<mat-spinner diameter="36"></mat-spinner>
|
||||
<span>Verbindungen zu Unternehmen werden geladen ...</span>
|
||||
</div>
|
||||
<app-loading
|
||||
text="Verbindungen zu Unternehmen werden geladen ..."
|
||||
icon="business"
|
||||
[size]="60"
|
||||
[diameter]="60" />
|
||||
} @else if (error) {
|
||||
<div class="state state-error">
|
||||
Verbindungen zu Unternehmen konnten nicht geladen werden.
|
||||
|
||||
+2
-2
@@ -14,7 +14,6 @@ import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatTooltip, MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { ActivatedRoute, Router, RouterModule } from '@angular/router';
|
||||
import { EChartsOption } from 'echarts';
|
||||
import { NgxEchartsDirective } from 'ngx-echarts';
|
||||
@@ -27,6 +26,7 @@ import {
|
||||
} from '../../api';
|
||||
import { PersonDataResolved } from '../../resolvers/person.resolver';
|
||||
import { ChartThemeService } from '../../shared/services/chart-theme.service';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
|
||||
interface RoleLegendItem {
|
||||
role: string;
|
||||
@@ -44,7 +44,6 @@ interface GraphSymbols {
|
||||
selector: 'app-person-company-connections',
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatProgressSpinnerModule,
|
||||
NgxEchartsDirective,
|
||||
MatButtonModule,
|
||||
MatCardModule,
|
||||
@@ -52,6 +51,7 @@ interface GraphSymbols {
|
||||
MatTooltipModule,
|
||||
MatTooltip,
|
||||
RouterModule,
|
||||
LoadingComponent,
|
||||
],
|
||||
templateUrl: './person-company-connections.component.html',
|
||||
styleUrl: './person-company-connections.component.scss',
|
||||
|
||||
@@ -123,22 +123,22 @@
|
||||
<h4>Publikationen</h4>
|
||||
<ul class="publication-list">
|
||||
@for (id of getSelectedPublicationIdsPage(); track id) {
|
||||
<li class="publication-item" (click)="togglePublication(id)">
|
||||
<li class="publication-item">
|
||||
<span class="publication-title">
|
||||
{{ getPublicationTitle(id) }}
|
||||
@if (expandedPublicationId === id) {
|
||||
<a
|
||||
class="publication-more-info"
|
||||
title="Publikationsdetails öffnen"
|
||||
[routerLink]="['/publication', getShortPublicationId(id)]"
|
||||
[state]="{
|
||||
returnUrl: getCurrentUrl(),
|
||||
returnLabel: 'Förderungen',
|
||||
}"
|
||||
(click)="$event.stopPropagation()">
|
||||
<span class="material-icons">open_in_new</span>
|
||||
</a>
|
||||
}
|
||||
<a
|
||||
class="publication-more-info"
|
||||
title="Publikationsdetails öffnen"
|
||||
[routerLink]="[
|
||||
'/publication',
|
||||
getShortPublicationId(id),
|
||||
]"
|
||||
[state]="{
|
||||
returnUrl: getCurrentUrl(),
|
||||
returnLabel: 'Förderungen',
|
||||
}">
|
||||
<span class="material-icons">open_in_new</span>
|
||||
</a>
|
||||
</span>
|
||||
</li>
|
||||
}
|
||||
|
||||
@@ -39,21 +39,14 @@ app-query-param-paginator {
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
overflow: hidden;
|
||||
border-collapse: collapse;
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding: 12px 16px;
|
||||
background: var(--sg-surface-muted);
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
@@ -68,10 +61,6 @@ app-query-param-paginator {
|
||||
&.selected td {
|
||||
background: var(--sg-primary-soft);
|
||||
}
|
||||
|
||||
&:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
@@ -97,24 +86,19 @@ app-query-param-paginator {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 26px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
min-width: 20px;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
|
||||
&--first {
|
||||
background: #effaf3;
|
||||
color: #24834f;
|
||||
}
|
||||
|
||||
&--middle {
|
||||
background: #f6f0ff;
|
||||
color: #7255d9;
|
||||
}
|
||||
|
||||
&--last {
|
||||
background: #fff1f2;
|
||||
color: #be123c;
|
||||
}
|
||||
}
|
||||
@@ -396,7 +380,6 @@ app-query-param-paginator {
|
||||
.publication-item {
|
||||
padding: 10px 14px;
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
cursor: pointer;
|
||||
transition: background-color 0.15s ease;
|
||||
|
||||
&:last-child {
|
||||
|
||||
@@ -56,7 +56,6 @@ export class PersonFundingComponent implements OnInit {
|
||||
sortMode: SortMode = 'name';
|
||||
loading = true;
|
||||
error = false;
|
||||
expandedPublicationId: string | null = null;
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.parent?.paramMap.subscribe((params) => {
|
||||
@@ -345,10 +344,6 @@ export class PersonFundingComponent implements OnInit {
|
||||
return parts[parts.length - 1] ?? publicationId;
|
||||
}
|
||||
|
||||
togglePublication(id: string): void {
|
||||
this.expandedPublicationId = this.expandedPublicationId === id ? null : id;
|
||||
}
|
||||
|
||||
getCurrentUrl(): string {
|
||||
return this.router.url;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,12 @@
|
||||
</app-topic-legend>
|
||||
<div class="interest-tags">
|
||||
@if (loading()) {
|
||||
<div class="interest-state interest-state-loading" aria-live="polite">
|
||||
<mat-spinner diameter="36"></mat-spinner>
|
||||
<span>Themen werden geladen ...</span>
|
||||
<div class="interest-tags-loading" aria-live="polite">
|
||||
<app-loading
|
||||
text="Themen werden geladen ..."
|
||||
icon="interests"
|
||||
[size]="48"
|
||||
[diameter]="48" />
|
||||
</div>
|
||||
} @else if (tags().length > 0) {
|
||||
@for (tag of tags(); track tag.label) {
|
||||
|
||||
@@ -35,6 +35,12 @@
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.interest-tags-loading {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.interest-footnote {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -58,25 +64,3 @@
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.interest-state {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
min-height: 90px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 20px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.interest-card-loading .interest-state {
|
||||
min-height: 48px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.interest-state-loading {
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ import {
|
||||
} from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { TopicCount } from '../../api';
|
||||
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { TopicLegendComponent } from '../../shared/ui/topic-legend/topic-legend.component';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import {
|
||||
buildTopicLegendGroups,
|
||||
@@ -52,9 +52,9 @@ const MAX_TAGS = 5;
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
TopicChipComponent,
|
||||
TopicLegendComponent,
|
||||
LoadingComponent,
|
||||
],
|
||||
templateUrl: './person-interesting.component.html',
|
||||
styleUrl: './person-interesting.component.scss',
|
||||
|
||||
@@ -69,15 +69,11 @@
|
||||
institutionFilterLabel(filter)
|
||||
}}</span>
|
||||
@if (filter.countryCode) {
|
||||
<img
|
||||
alt=""
|
||||
<app-country-flag
|
||||
class="filter-institution-chip__flag"
|
||||
[src]="
|
||||
'https://flagcdn.io/' +
|
||||
filter.countryCode.toLowerCase() +
|
||||
'.svg'
|
||||
"
|
||||
height="10" />
|
||||
[countryCode]="filter.countryCode"
|
||||
[height]="10"
|
||||
[bordered]="false" />
|
||||
<span class="filter-institution-chip__country">{{
|
||||
filter.countryCode.toUpperCase()
|
||||
}}</span>
|
||||
|
||||
@@ -210,7 +210,6 @@
|
||||
.filter-institution-chip__flag {
|
||||
flex-shrink: 0;
|
||||
margin-left: 6px;
|
||||
border: 1px solid var(--sg-primary-border, var(--sg-border));
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,13 @@ import {
|
||||
DehydratedInstitution,
|
||||
PersonsService,
|
||||
InstitutionsService,
|
||||
InstitutionsV2Service,
|
||||
WorkTopic,
|
||||
} from '../../api';
|
||||
import { TopicsService } from '../../api/api/topics.service';
|
||||
import { TopicHierarchyComponent } from '../topic-hierarchy/topic-hierarchy.component';
|
||||
import { PersonCardComponent } from '../person-card/person-card.component';
|
||||
import { CountryFlagComponent } from '../../shared/ui/country-flag/country-flag.component';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import { buildTopicHierarchyTooltip } from '../../resolvers/utils/topic-tooltip';
|
||||
import { SharedStateService } from '../../shared/services/shared-state.service';
|
||||
@@ -64,6 +66,7 @@ type InstitutionYearFilterMode = 'in' | 'from' | 'between';
|
||||
PersonCardComponent,
|
||||
SkTextDirective,
|
||||
MatAutocompleteModule,
|
||||
CountryFlagComponent,
|
||||
],
|
||||
templateUrl: './person-list.component.html',
|
||||
styleUrl: './person-list.component.scss',
|
||||
@@ -75,6 +78,7 @@ export class PersonListComponent {
|
||||
private readonly personsService = inject(PersonsService);
|
||||
private readonly topicsService = inject(TopicsService);
|
||||
private readonly institutionsService = inject(InstitutionsService);
|
||||
private readonly institutionsV2Service = inject(InstitutionsV2Service);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly bookmarkService = inject(BookmarkService);
|
||||
public readonly state = inject(SharedStateService);
|
||||
@@ -643,9 +647,16 @@ export class PersonListComponent {
|
||||
}
|
||||
|
||||
private searchInstitutions(query: string) {
|
||||
return this.institutionsService
|
||||
.autocompleteInstitutions(query, undefined, undefined, 10)
|
||||
.pipe(map((response) => response.results ?? []));
|
||||
return this.institutionsV2Service
|
||||
.getInstitutionAutocompleteForSelector(query)
|
||||
.pipe(
|
||||
map((response) =>
|
||||
(response.elements ?? []).map((inst) => ({
|
||||
...inst,
|
||||
hint: [inst.country_code, inst.type].filter(Boolean).join(' · '),
|
||||
})),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
updateYearFilterState(institution: DehydratedInstitution | null): void {
|
||||
|
||||
+8
-49
@@ -56,56 +56,15 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
<app-year-range-slider
|
||||
*ngIf="hasYearRange"
|
||||
class="year-filter"
|
||||
aria-label="Zeitraum eingrenzen">
|
||||
<div class="year-filter-top">
|
||||
<span class="year-filter-label">Zeitraum</span>
|
||||
|
||||
<span class="year-filter-values">
|
||||
{{ selectedStartYear }} bis {{ selectedEndYear }}
|
||||
</span>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="reset-range-button"
|
||||
[disabled]="!canResetYearRange"
|
||||
(click)="resetYearRange()">
|
||||
Zurücksetzen
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="year-range-slider"
|
||||
[style.--range-start]="rangeStartPercent"
|
||||
[style.--range-end]="rangeEndPercent">
|
||||
<div class="range-track"></div>
|
||||
|
||||
<input
|
||||
class="range-input range-input-start"
|
||||
type="range"
|
||||
[min]="minYear"
|
||||
[max]="maxYear"
|
||||
[value]="selectedStartYear"
|
||||
(input)="onStartYearInput($event)"
|
||||
aria-label="Startjahr" />
|
||||
|
||||
<input
|
||||
class="range-input range-input-end"
|
||||
type="range"
|
||||
[min]="minYear"
|
||||
[max]="maxYear"
|
||||
[value]="selectedEndYear"
|
||||
(input)="onEndYearInput($event)"
|
||||
aria-label="Endjahr" />
|
||||
</div>
|
||||
|
||||
<div class="year-filter-bounds">
|
||||
<span>{{ minYear }}</span>
|
||||
<span>{{ maxYear }}</span>
|
||||
</div>
|
||||
</div>
|
||||
class="timeline-year-filter"
|
||||
[minYear]="minYear"
|
||||
[maxYear]="maxYear"
|
||||
[startYear]="selectedStartYear"
|
||||
[endYear]="selectedEndYear"
|
||||
(startYearChange)="onYearRangeSliderStartChange($event)"
|
||||
(endYearChange)="onYearRangeSliderEndChange($event)" />
|
||||
</div>
|
||||
|
||||
<ng-container *ngIf="timelineViewMode === 'wordcloud'; else timelineViews">
|
||||
|
||||
+3
-131
@@ -110,143 +110,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
.year-filter {
|
||||
.timeline-year-filter {
|
||||
grid-column: 3;
|
||||
grid-row: 1;
|
||||
justify-self: end;
|
||||
width: min(var(--year-filter-width), 100%);
|
||||
padding: 5px 10px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 10px;
|
||||
background: var(--sg-surface-muted);
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.year-filter-top,
|
||||
.year-filter-values,
|
||||
.year-filter-bounds,
|
||||
.phase-meta-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.year-filter-top,
|
||||
.phase-meta-row {
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.year-filter-top {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.year-filter-label {
|
||||
color: var(--sg-text);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.reset-range-button {
|
||||
color: var(--accent);
|
||||
font-size: 11px;
|
||||
|
||||
&:disabled {
|
||||
color: var(--sg-text-soft);
|
||||
}
|
||||
}
|
||||
|
||||
.year-filter-values {
|
||||
gap: 5px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.year-filter-bounds {
|
||||
justify-content: space-between;
|
||||
margin-top: 0;
|
||||
color: var(--sg-text-soft);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.year-range-slider {
|
||||
--range-start: 0%;
|
||||
--range-end: 100%;
|
||||
|
||||
position: relative;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.range-track {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 5px;
|
||||
transform: translateY(-50%);
|
||||
border-radius: 999px;
|
||||
background: linear-gradient(
|
||||
to right,
|
||||
var(--sg-border) 0%,
|
||||
var(--sg-border) var(--range-start),
|
||||
var(--accent) var(--range-start),
|
||||
var(--accent) var(--range-end),
|
||||
var(--sg-border) var(--range-end),
|
||||
var(--sg-border) 100%
|
||||
);
|
||||
}
|
||||
|
||||
.range-input {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
width: 100%;
|
||||
height: 22px;
|
||||
margin: 0;
|
||||
appearance: none;
|
||||
background: transparent;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.range-input::-webkit-slider-runnable-track,
|
||||
.range-input::-moz-range-track {
|
||||
height: 5px;
|
||||
background: transparent;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.range-input::-webkit-slider-thumb {
|
||||
appearance: none;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
margin-top: -5px;
|
||||
border: 2px solid var(--sg-surface);
|
||||
border-radius: 50%;
|
||||
background: var(--accent);
|
||||
box-shadow: var(--sg-shadow-sm);
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.range-input::-moz-range-thumb {
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border: 2px solid var(--sg-surface);
|
||||
border-radius: 50%;
|
||||
background: var(--accent);
|
||||
box-shadow: var(--sg-shadow-sm);
|
||||
cursor: pointer;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.range-input-start {
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.range-input-end {
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.timeline-wrapper {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
@@ -565,11 +442,6 @@ app-topic-chip.timeline-topic-chip {
|
||||
gap: 7px;
|
||||
}
|
||||
|
||||
.timeline-title .reset-range-button {
|
||||
display: inline-flex;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.timeline-title > .no-topics {
|
||||
display: block;
|
||||
margin-top: 6px;
|
||||
@@ -603,7 +475,7 @@ app-topic-chip.timeline-topic-chip {
|
||||
.timeline-title,
|
||||
.timeline-legend,
|
||||
.view-toggle,
|
||||
.year-filter {
|
||||
.timeline-year-filter {
|
||||
grid-column: auto;
|
||||
grid-row: auto;
|
||||
}
|
||||
@@ -616,7 +488,7 @@ app-topic-chip.timeline-topic-chip {
|
||||
justify-self: start;
|
||||
}
|
||||
|
||||
.year-filter {
|
||||
.timeline-year-filter {
|
||||
justify-self: stretch;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
+6
-64
@@ -14,6 +14,7 @@ import {
|
||||
} from '@angular/core';
|
||||
import { TopicChipComponent } from '../../../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { TopicLegendComponent } from '../../../../shared/ui/topic-legend/topic-legend.component';
|
||||
import { YearRangeSliderComponent } from '../../../../shared/ui/year-range-slider/year-range-slider.component';
|
||||
import { topicHierarchyColor } from '../../../../resolvers/utils/topic-colors';
|
||||
import {
|
||||
buildTopicLegendGroups,
|
||||
@@ -97,6 +98,7 @@ interface TimelineScrollAnchor {
|
||||
MatTooltipModule,
|
||||
TopicChipComponent,
|
||||
TopicLegendComponent,
|
||||
YearRangeSliderComponent,
|
||||
],
|
||||
templateUrl: './research-timeline.component.html',
|
||||
styleUrl: './research-timeline.component.scss',
|
||||
@@ -200,13 +202,6 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
return this.minYear > 0 && this.maxYear > 0 && this.minYear < this.maxYear;
|
||||
}
|
||||
|
||||
get canResetYearRange(): boolean {
|
||||
return (
|
||||
this.selectedStartYear !== this.minYear ||
|
||||
this.selectedEndYear !== this.maxYear
|
||||
);
|
||||
}
|
||||
|
||||
get showEarlierYearsControl(): boolean {
|
||||
return this.canLoadEarlierYears || this.loadingEarlierYears;
|
||||
}
|
||||
@@ -223,14 +218,6 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
return 'Frühere Jahre anzeigen';
|
||||
}
|
||||
|
||||
get rangeStartPercent(): string {
|
||||
return `${this.calculateRangePercent(this.selectedStartYear)}%`;
|
||||
}
|
||||
|
||||
get rangeEndPercent(): string {
|
||||
return `${this.calculateRangePercent(this.selectedEndYear)}%`;
|
||||
}
|
||||
|
||||
get gridTemplateColumns(): string {
|
||||
const count = Math.max(
|
||||
this.timelineItems.length + this.earlierYearsColumnCount,
|
||||
@@ -266,33 +253,13 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
this.viewModeChange.emit(mode);
|
||||
}
|
||||
|
||||
onStartYearInput(event: Event): void {
|
||||
const nextStartYear = this.parseYearInput(event);
|
||||
|
||||
this.selectedStartYear = this.clampYear(nextStartYear);
|
||||
|
||||
if (this.selectedStartYear > this.selectedEndYear) {
|
||||
this.selectedEndYear = this.selectedStartYear;
|
||||
}
|
||||
|
||||
onYearRangeSliderStartChange(year: number): void {
|
||||
this.selectedStartYear = year;
|
||||
this.emitYearRangeChange();
|
||||
}
|
||||
|
||||
onEndYearInput(event: Event): void {
|
||||
const nextEndYear = this.parseYearInput(event);
|
||||
|
||||
this.selectedEndYear = this.clampYear(nextEndYear);
|
||||
|
||||
if (this.selectedEndYear < this.selectedStartYear) {
|
||||
this.selectedStartYear = this.selectedEndYear;
|
||||
}
|
||||
|
||||
this.emitYearRangeChange();
|
||||
}
|
||||
|
||||
resetYearRange(): void {
|
||||
this.selectedStartYear = this.minYear;
|
||||
this.selectedEndYear = this.maxYear;
|
||||
onYearRangeSliderEndChange(year: number): void {
|
||||
this.selectedEndYear = year;
|
||||
this.emitYearRangeChange();
|
||||
}
|
||||
|
||||
@@ -1003,35 +970,10 @@ export class ResearchTimelineComponent implements OnChanges, AfterViewChecked {
|
||||
return topicName.trim().toLowerCase();
|
||||
}
|
||||
|
||||
private parseYearInput(event: Event): number {
|
||||
const input = event.target as HTMLInputElement | null;
|
||||
const value = Number(input?.value ?? this.minYear);
|
||||
|
||||
if (!Number.isFinite(value)) {
|
||||
return this.minYear;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private clampYear(year: number): number {
|
||||
return Math.min(Math.max(year, this.minYear), this.maxYear);
|
||||
}
|
||||
|
||||
private calculateRangePercent(year: number): number {
|
||||
if (!this.hasYearRange) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const totalRange = this.maxYear - this.minYear;
|
||||
|
||||
if (totalRange <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ((year - this.minYear) / totalRange) * 100;
|
||||
}
|
||||
|
||||
private isTimelineViewMode(value: string): value is TimelineViewMode {
|
||||
return value === 'years' || value === 'compact' || value === 'wordcloud';
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
TopicTimelineElement,
|
||||
TopicTimelineTopic,
|
||||
} from './components/research-timeline/research-timeline.component';
|
||||
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
|
||||
import { TopicLegendTopic } from '../../resolvers/utils/topic-legend';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import { buildTopicHierarchyTooltip } from '../../resolvers/utils/topic-tooltip';
|
||||
@@ -184,12 +185,9 @@ export class PersonOverviewComponent implements OnInit {
|
||||
void this.router.navigate(['../publications'], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
publicationPage: 1,
|
||||
publicationYear: selection.years,
|
||||
publicationTopicId: selection.topic.id,
|
||||
publicationTopicName: selection.topic.name,
|
||||
publicationTopicField: selection.topic.field_name ?? null,
|
||||
publicationTopicDomain: selection.topic.domain_name ?? null,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.years]: selection.years,
|
||||
[workQueryParamKeys.topicId]: selection.topic.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -202,8 +200,8 @@ export class PersonOverviewComponent implements OnInit {
|
||||
void this.router.navigate(['../publications'], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
publicationPage: 1,
|
||||
publicationYear: years,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.years]: years,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -226,11 +224,8 @@ export class PersonOverviewComponent implements OnInit {
|
||||
void this.router.navigate(['../publications'], {
|
||||
relativeTo: this.route,
|
||||
queryParams: {
|
||||
publicationPage: 1,
|
||||
publicationTopicId: word.topicId,
|
||||
publicationTopicName: word.name,
|
||||
publicationTopicField: word.fieldName ?? null,
|
||||
publicationTopicDomain: word.domainName ?? null,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.topicId]: word.topicId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -44,21 +44,14 @@ app-query-param-paginator {
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
overflow: hidden;
|
||||
border-collapse: collapse;
|
||||
|
||||
th {
|
||||
text-align: left;
|
||||
padding: 12px 16px;
|
||||
background: var(--sg-surface-muted);
|
||||
border-bottom: 1px solid var(--sg-border);
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.02em;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
@@ -74,10 +67,6 @@ app-query-param-paginator {
|
||||
&.selected td {
|
||||
background: var(--sg-primary-soft);
|
||||
}
|
||||
|
||||
&:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
td {
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
<a
|
||||
matTabLink
|
||||
[routerLink]="[route.path]"
|
||||
[queryParams]="{
|
||||
authorId: null,
|
||||
institutionId: null,
|
||||
agency: null,
|
||||
}"
|
||||
queryParamsHandling="merge"
|
||||
routerLinkActive
|
||||
#rla="routerLinkActive"
|
||||
|
||||
@@ -41,13 +41,7 @@
|
||||
}
|
||||
@if (countryCode(); as countryCode) {
|
||||
<span class="institution-country">
|
||||
<img
|
||||
alt=""
|
||||
class="flag-img"
|
||||
[src]="
|
||||
'https://flagcdn.io/' + countryCode.toLowerCase() + '.svg'
|
||||
"
|
||||
height="12" />
|
||||
<app-country-flag [countryCode]="countryCode" [rounded]="true" />
|
||||
{{ countryCode }}
|
||||
</span>
|
||||
}
|
||||
@@ -99,19 +93,9 @@
|
||||
}
|
||||
@if (displayCareerStage() || orcid()) {
|
||||
<div class="meta-line">
|
||||
@if (displayCareerStage()) {
|
||||
<div class="career-stage-line">
|
||||
<span class="career-stage-label">Career Stage:</span>
|
||||
<span
|
||||
class="career-stage-chip"
|
||||
[matTooltip]="careerStageTooltip()"
|
||||
matTooltipPosition="right"
|
||||
matTooltipClass="career-stage-tooltip"
|
||||
[matTooltipShowDelay]="250">
|
||||
{{ displayCareerStage() }}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
<app-career-stage-chip
|
||||
[careerStage]="displayCareerStage()"
|
||||
[activeYears]="person()?.career_metrics?.active_years" />
|
||||
@if (orcid(); as orcidId) {
|
||||
<a
|
||||
class="orcid-chip"
|
||||
|
||||
@@ -158,11 +158,6 @@
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.institution-country .flag-img {
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.stat-item.has-tooltip {
|
||||
cursor: help;
|
||||
}
|
||||
@@ -175,33 +170,6 @@
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.career-stage-line {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.career-stage-label {
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.career-stage-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-height: 24px;
|
||||
padding: 2px 10px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 999px;
|
||||
background: var(--sg-surface-muted);
|
||||
color: var(--sg-primary);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
line-height: 1.2;
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.orcid-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import { DecimalPipe } from '@angular/common';
|
||||
import { Component, computed, inject, signal, DestroyRef } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
computed,
|
||||
inject,
|
||||
signal,
|
||||
DestroyRef,
|
||||
input,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
toSignal,
|
||||
toObservable,
|
||||
@@ -17,12 +24,15 @@ import {
|
||||
import { of, switchMap, finalize, map, catchError, combineLatest } from 'rxjs';
|
||||
|
||||
import { PersonInterestingComponent } from '../person-interesting/person-interesting.component';
|
||||
import { CountryFlagComponent } from '../../shared/ui/country-flag/country-flag.component';
|
||||
import { CareerStageChipComponent } from '../../shared/ui/career-stage-chip/career-stage-chip.component';
|
||||
import { WorksService } from '../../api';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
import { PersonBioResolved } from '../../resolvers/person-bio.resolver';
|
||||
import { PersonDataResolved } from '../../resolvers/person.resolver';
|
||||
import { BookmarkService } from '../../shared/services/bookmark.service';
|
||||
import { collaborationGraphQueryParamKeys } from '../../resolvers/collaboration-graph.resolver';
|
||||
import { workQueryParamKeys } from '../../resolvers/work-page.resolver';
|
||||
|
||||
type PersonLink = {
|
||||
label: string;
|
||||
@@ -43,6 +53,8 @@ type PersonLink = {
|
||||
RouterOutlet,
|
||||
RouterModule,
|
||||
LoadingComponent,
|
||||
CountryFlagComponent,
|
||||
CareerStageChipComponent,
|
||||
],
|
||||
templateUrl: './person.component.html',
|
||||
styleUrl: './person.component.scss',
|
||||
@@ -55,6 +67,8 @@ export class PersonComponent {
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
readonly bookmarkService = inject(BookmarkService);
|
||||
|
||||
canFetchGdprRelevantData = input.required<boolean>();
|
||||
|
||||
constructor() {
|
||||
this.bookmarkService
|
||||
.load()
|
||||
@@ -187,27 +201,6 @@ export class PersonComponent {
|
||||
|
||||
return stage;
|
||||
});
|
||||
readonly careerStageTooltip = computed(() => {
|
||||
const stage = this.displayCareerStage();
|
||||
if (!stage) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const activeYears = this.person()?.career_metrics?.active_years ?? '-';
|
||||
|
||||
return [
|
||||
`Aktuell: ${stage.replace(' Researcher', '')}`,
|
||||
`Aktive Publikationsjahre: ${activeYears}`,
|
||||
'',
|
||||
'Einteilung:',
|
||||
'Early: 1\u20134 aktive Publikationsjahre',
|
||||
'Emerging: 5\u20139 aktive Publikationsjahre',
|
||||
'Established: 10\u201314 aktive Publikationsjahre',
|
||||
'Senior: ab 15 aktiven Publikationsjahren',
|
||||
'',
|
||||
'Diese Einschätzung basiert ausschließlich auf OpenAlex-Publikationsdaten und ist kein offizieller akademischer Status.',
|
||||
].join('\n');
|
||||
});
|
||||
readonly orcid = computed(() => {
|
||||
const rawOrcid = this.getId('orcid');
|
||||
if (!rawOrcid) {
|
||||
@@ -243,73 +236,80 @@ export class PersonComponent {
|
||||
{ initialValue: [] },
|
||||
);
|
||||
|
||||
readonly links = computed<PersonLink[]>(() => [
|
||||
{
|
||||
label: 'Übersicht',
|
||||
description: 'Übersicht über die Person',
|
||||
path: 'overview',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Projekte',
|
||||
description: 'Übersicht der durchgeführten Projekte der Person',
|
||||
path: 'projects',
|
||||
queryParams: {
|
||||
page: 0,
|
||||
size: 10,
|
||||
sort_by: 'title',
|
||||
sort_direction: 'asc',
|
||||
search: '',
|
||||
readonly links = computed<PersonLink[]>(() => {
|
||||
const links = [
|
||||
{
|
||||
label: 'Übersicht',
|
||||
description: 'Übersicht über die Person',
|
||||
path: 'overview',
|
||||
disabled: false,
|
||||
},
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Publikationen',
|
||||
description: 'Übersicht der Publikationen der Person',
|
||||
path: 'publications',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Netzwerk',
|
||||
description: 'Kooperationsnetzwerk der Person',
|
||||
path: 'network',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
[collaborationGraphQueryParamKeys.minCollaborators]: '2',
|
||||
[collaborationGraphQueryParamKeys.maxCollaborators]: '10',
|
||||
[collaborationGraphQueryParamKeys.yearFrom]: '1900',
|
||||
[collaborationGraphQueryParamKeys.yearTo]: new Date().getFullYear(),
|
||||
...(this.canFetchGdprRelevantData()
|
||||
? [
|
||||
{
|
||||
label: 'Projekte',
|
||||
description: 'Übersicht der durchgeführten Projekte der Person',
|
||||
path: 'projects',
|
||||
queryParams: {
|
||||
page: 0,
|
||||
size: 10,
|
||||
sort_by: 'title',
|
||||
sort_direction: 'asc',
|
||||
search: '',
|
||||
},
|
||||
disabled: false,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: 'Publikationen',
|
||||
description: 'Übersicht der Publikationen der Person',
|
||||
path: 'publications',
|
||||
disabled: false,
|
||||
},
|
||||
},
|
||||
...(this.companyConnectionsAvailable()
|
||||
? [
|
||||
{
|
||||
label: 'Unternehmen',
|
||||
description: 'Unternehmen, mit denen die Person verbunden ist',
|
||||
path: 'company-connections',
|
||||
disabled: false,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: 'Förderungen',
|
||||
description: 'Übersicht der Förderungen der Person',
|
||||
path: 'funding',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Nachrichten',
|
||||
description: 'Nachrichten über die Person',
|
||||
path: 'news',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Patente',
|
||||
description: 'Patente der Person',
|
||||
path: 'patents',
|
||||
disabled: false,
|
||||
},
|
||||
]);
|
||||
{
|
||||
label: 'Netzwerk',
|
||||
description: 'Kooperationsnetzwerk der Person',
|
||||
path: 'network',
|
||||
disabled: false,
|
||||
queryParams: {
|
||||
[collaborationGraphQueryParamKeys.minCollaborators]: '2',
|
||||
[collaborationGraphQueryParamKeys.maxCollaborators]: '10',
|
||||
[collaborationGraphQueryParamKeys.yearFrom]: '1900',
|
||||
[collaborationGraphQueryParamKeys.yearTo]: new Date().getFullYear(),
|
||||
},
|
||||
},
|
||||
...(this.companyConnectionsAvailable()
|
||||
? [
|
||||
{
|
||||
label: 'Unternehmen',
|
||||
description: 'Unternehmen, mit denen die Person verbunden ist',
|
||||
path: 'company-connections',
|
||||
disabled: false,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
label: 'Förderungen',
|
||||
description: 'Übersicht der Förderungen der Person',
|
||||
path: 'funding',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Nachrichten',
|
||||
description: 'Nachrichten über die Person',
|
||||
path: 'news',
|
||||
disabled: false,
|
||||
},
|
||||
{
|
||||
label: 'Patente',
|
||||
description: 'Patente der Person',
|
||||
path: 'patents',
|
||||
disabled: false,
|
||||
},
|
||||
];
|
||||
return links;
|
||||
});
|
||||
|
||||
readonly activeLink = computed<PersonLink | null>(() => {
|
||||
const currentUrl = this.currentUrl();
|
||||
@@ -342,8 +342,8 @@ export class PersonComponent {
|
||||
void this.router.navigate(['publications'], {
|
||||
relativeTo: this.activatedRoute,
|
||||
queryParams: {
|
||||
page: 0,
|
||||
publicationTopicId: selection.id,
|
||||
[workQueryParamKeys.page]: 0,
|
||||
[workQueryParamKeys.topicId]: selection.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
<section class="preprocessing-page">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<h1>Jobs</h1>
|
||||
<p>
|
||||
Tasks zur Aufbereitung und Indizierung der Daten manuell ausführen oder
|
||||
automatisch planen.
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<mat-card appearance="outlined" class="container-card">
|
||||
<mat-card-content class="container-card-content">
|
||||
<div class="container-info">
|
||||
<span
|
||||
class="container-state-dot"
|
||||
[class.container-state-dot--running]="
|
||||
containerStatus().state === 'running'
|
||||
"
|
||||
[class.container-state-dot--stopped]="
|
||||
containerStatus().state === 'stopped'
|
||||
"
|
||||
[class.container-state-dot--restarting]="
|
||||
containerStatus().state === 'restarting'
|
||||
">
|
||||
</span>
|
||||
<div>
|
||||
<strong>{{ containerStatus().name }}</strong>
|
||||
<div class="container-meta">
|
||||
<span>{{ containerStatus().image }}</span>
|
||||
<span class="container-digest">{{
|
||||
containerStatus().imageDigest
|
||||
}}</span>
|
||||
@switch (containerStatus().state) {
|
||||
@case ('running') {
|
||||
<span
|
||||
>Läuft{{
|
||||
containerStatus().uptime
|
||||
? ' · seit ' + containerStatus().uptime
|
||||
: ''
|
||||
}}</span
|
||||
>
|
||||
}
|
||||
@case ('stopped') {
|
||||
<span>Gestoppt</span>
|
||||
}
|
||||
@case ('restarting') {
|
||||
<span>Wird neu gestartet …</span>
|
||||
}
|
||||
}
|
||||
@if (containerStatus().updateAvailable) {
|
||||
<span class="update-badge">
|
||||
<mat-icon>upgrade</mat-icon>
|
||||
Neue Version verfügbar
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container-actions">
|
||||
@if (containerStatus().updateAvailable) {
|
||||
<button
|
||||
mat-flat-button
|
||||
color="primary"
|
||||
type="button"
|
||||
[disabled]="containerBusy()"
|
||||
(click)="updateImage()">
|
||||
<mat-icon>upgrade</mat-icon>
|
||||
Image aktualisieren
|
||||
</button>
|
||||
}
|
||||
@if (containerStatus().state === 'running') {
|
||||
<button
|
||||
mat-stroked-button
|
||||
type="button"
|
||||
[disabled]="containerBusy()"
|
||||
(click)="restartContainer()">
|
||||
<mat-icon>restart_alt</mat-icon>
|
||||
Neu starten
|
||||
</button>
|
||||
<button
|
||||
mat-stroked-button
|
||||
color="warn"
|
||||
type="button"
|
||||
[disabled]="containerBusy()"
|
||||
(click)="stopContainer()">
|
||||
<mat-icon>stop</mat-icon>
|
||||
Stoppen
|
||||
</button>
|
||||
} @else {
|
||||
<button
|
||||
mat-flat-button
|
||||
color="primary"
|
||||
type="button"
|
||||
[disabled]="containerBusy()"
|
||||
(click)="startContainer()">
|
||||
<mat-icon>play_arrow</mat-icon>
|
||||
Starten
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
|
||||
<mat-card appearance="outlined">
|
||||
<mat-card-content>
|
||||
<app-data-table [columns]="taskColumns" [data]="tasks()" />
|
||||
</mat-card-content>
|
||||
</mat-card>
|
||||
</section>
|
||||
|
||||
<ng-template #taskNameTmp let-row>
|
||||
<div class="task-name-cell">
|
||||
<strong>{{ row.name }}</strong>
|
||||
<span class="task-description">{{ row.description }}</span>
|
||||
<code class="task-index">{{ row.targetIndex }}</code>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #taskScheduleTmp let-row>
|
||||
<div class="task-schedule-cell">
|
||||
<span>{{ formatSchedule(row.schedule) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
role="switch"
|
||||
class="schedule-toggle"
|
||||
[class.schedule-toggle--on]="row.enabled"
|
||||
[attr.aria-checked]="row.enabled"
|
||||
[attr.aria-label]="row.name + ': automatische Ausführung'"
|
||||
(click)="toggleEnabled(row, !row.enabled)">
|
||||
<span class="schedule-toggle__track">
|
||||
<span class="schedule-toggle__thumb"></span>
|
||||
</span>
|
||||
<span class="schedule-toggle__label">{{
|
||||
row.enabled ? 'Aktiv' : 'Inaktiv'
|
||||
}}</span>
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
|
||||
<ng-template #taskStatusTmp let-row>
|
||||
@switch (row.status) {
|
||||
@case ('running') {
|
||||
<span class="task-status task-status--running">
|
||||
<mat-progress-spinner
|
||||
diameter="14"
|
||||
mode="indeterminate"></mat-progress-spinner>
|
||||
Läuft
|
||||
</span>
|
||||
}
|
||||
@case ('success') {
|
||||
<span class="task-status task-status--success">
|
||||
<mat-icon>check_circle</mat-icon>
|
||||
Erfolgreich
|
||||
</span>
|
||||
}
|
||||
@case ('failed') {
|
||||
<span class="task-status task-status--failed">
|
||||
<mat-icon>error</mat-icon>
|
||||
Fehlgeschlagen
|
||||
</span>
|
||||
}
|
||||
@default {
|
||||
<span class="task-status task-status--idle">
|
||||
<mat-icon>schedule</mat-icon>
|
||||
Bereit
|
||||
</span>
|
||||
}
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #taskLastRunTmp let-row>
|
||||
@if (row.lastRun) {
|
||||
<div class="last-run-cell">
|
||||
<span>{{ row.lastRun.startedAt | date: 'dd.MM.yyyy HH:mm' }}</span>
|
||||
<span class="last-run-message">{{ row.lastRun.message }}</span>
|
||||
</div>
|
||||
} @else {
|
||||
<span class="last-run-empty">Noch nicht ausgeführt</span>
|
||||
}
|
||||
</ng-template>
|
||||
|
||||
<ng-template #taskActionsTmp let-row>
|
||||
<div class="row-actions">
|
||||
<button
|
||||
mat-icon-button
|
||||
type="button"
|
||||
aria-label="Jetzt ausführen"
|
||||
matTooltip="Jetzt ausführen"
|
||||
[disabled]="row.status === 'running'"
|
||||
(click)="runNow(row)">
|
||||
<mat-icon>play_arrow</mat-icon>
|
||||
</button>
|
||||
<button
|
||||
mat-icon-button
|
||||
type="button"
|
||||
aria-label="Zeitplan bearbeiten"
|
||||
matTooltip="Zeitplan bearbeiten"
|
||||
(click)="openScheduleDialog(row)">
|
||||
<mat-icon>edit_calendar</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</ng-template>
|
||||
@@ -139,41 +139,6 @@
|
||||
</mat-card>
|
||||
}
|
||||
|
||||
<!-- Beteiligte Institutionen -->
|
||||
@if (getInstitutions().length > 0) {
|
||||
<mat-card appearance="outlined" class="card">
|
||||
<div class="section-header">
|
||||
<mat-icon>business</mat-icon>
|
||||
<h2>Beteiligte Institutionen</h2>
|
||||
<span class="count-badge">{{ getInstitutions().length }}</span>
|
||||
</div>
|
||||
<div class="institution-grid">
|
||||
@for (institution of getInstitutions(); track institution) {
|
||||
<div
|
||||
class="institution-item"
|
||||
(click)="searchForInstitutionName(institution)">
|
||||
<mat-icon>apartment</mat-icon>
|
||||
<span>{{ institution }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</mat-card>
|
||||
}
|
||||
|
||||
<!-- Joint Project Information
|
||||
@if (bundProject.joint_project) {
|
||||
<mat-card appearance="outlined" class="card">
|
||||
<div class="section-header">
|
||||
<mat-icon>groups</mat-icon>
|
||||
<h2>Gemeinschaftsprojekt</h2>
|
||||
</div>
|
||||
<div class="joint-project-content">
|
||||
<mat-icon>link</mat-icon>
|
||||
<span>{{ bundProject.joint_project }}</span>
|
||||
</div>
|
||||
</mat-card>
|
||||
} -->
|
||||
<!-- Organisatorische Details -->
|
||||
@if (
|
||||
bundProject.executing_agency ||
|
||||
bundProject.funding_recipient ||
|
||||
@@ -183,14 +148,18 @@
|
||||
) {
|
||||
<mat-card appearance="outlined" class="card">
|
||||
<div class="section-header">
|
||||
<mat-icon>organization</mat-icon>
|
||||
<h2>Organisation</h2>
|
||||
<mat-icon>business</mat-icon>
|
||||
<h2>Beteiligte Institution</h2>
|
||||
</div>
|
||||
<dl class="details-list">
|
||||
@if (bundProject.executing_agency) {
|
||||
<div class="detail-row">
|
||||
<dt>Ausführende Stelle</dt>
|
||||
<dd>
|
||||
<dd
|
||||
class="clickable"
|
||||
(click)="
|
||||
searchForInstitutionName(bundProject.executing_agency)
|
||||
">
|
||||
{{ bundProject.executing_agency }}
|
||||
</dd>
|
||||
</div>
|
||||
@@ -198,13 +167,26 @@
|
||||
@if (bundProject.funding_recipient) {
|
||||
<div class="detail-row">
|
||||
<dt>Förderempfänger</dt>
|
||||
<dd>{{ bundProject.funding_recipient }}</dd>
|
||||
<dd
|
||||
class="clickable"
|
||||
(click)="
|
||||
searchForInstitutionName(bundProject.funding_recipient)
|
||||
">
|
||||
{{ bundProject.funding_recipient }}
|
||||
</dd>
|
||||
</div>
|
||||
}
|
||||
@if (bundProject.project_agency) {
|
||||
<div class="detail-row">
|
||||
<dt>Projektagentur</dt>
|
||||
<dd>
|
||||
<dd
|
||||
class="clickable"
|
||||
(click)="
|
||||
searchForInstitutionName(
|
||||
bundProject.project_agency_fullname ||
|
||||
bundProject.project_agency
|
||||
)
|
||||
">
|
||||
{{
|
||||
bundProject.project_agency_fullname ||
|
||||
bundProject.project_agency
|
||||
@@ -215,7 +197,14 @@
|
||||
@if (bundProject.department) {
|
||||
<div class="detail-row">
|
||||
<dt>Abteilung</dt>
|
||||
<dd>
|
||||
<dd
|
||||
class="clickable"
|
||||
(click)="
|
||||
searchForInstitutionName(
|
||||
bundProject.department_fullname ||
|
||||
bundProject.department
|
||||
)
|
||||
">
|
||||
{{
|
||||
bundProject.department_fullname || bundProject.department
|
||||
}}
|
||||
@@ -225,7 +214,11 @@
|
||||
@if (bundProject.division) {
|
||||
<div class="detail-row">
|
||||
<dt>Division</dt>
|
||||
<dd>{{ bundProject.division }}</dd>
|
||||
<dd
|
||||
class="clickable"
|
||||
(click)="searchForInstitutionName(bundProject.division)">
|
||||
{{ bundProject.division }}
|
||||
</dd>
|
||||
</div>
|
||||
}
|
||||
</dl>
|
||||
|
||||
@@ -5,6 +5,11 @@ import { MatCardModule } from '@angular/material/card';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { BundProjectDetails } from '../../../api/model/bundProjectDetails';
|
||||
import { ProjectOaTopicsComponent } from '../../../shared/ui/project-oa-topics/project-oa-topics.component';
|
||||
|
||||
export interface InstitutionEntry {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
@Component({
|
||||
selector: 'app-bund-details',
|
||||
standalone: true,
|
||||
@@ -57,45 +62,48 @@ export class BundDetailsComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
searchForInstitutionName(institutionName: string): void {
|
||||
this.router.navigate(['/institutions'], {
|
||||
queryParams: {
|
||||
search: institutionName,
|
||||
},
|
||||
});
|
||||
getInstitutions(): InstitutionEntry[] {
|
||||
const bp = this.bundProject;
|
||||
if (!bp) return [];
|
||||
|
||||
const institutions: InstitutionEntry[] = [];
|
||||
|
||||
if (bp.executing_agency) {
|
||||
institutions.push({
|
||||
label: 'Ausführende Stelle',
|
||||
value: bp.executing_agency,
|
||||
});
|
||||
}
|
||||
if (bp.funding_recipient) {
|
||||
institutions.push({
|
||||
label: 'Förderempfänger',
|
||||
value: bp.funding_recipient,
|
||||
});
|
||||
}
|
||||
if (bp.project_agency) {
|
||||
institutions.push({
|
||||
label: 'Projektagentur',
|
||||
value: bp.project_agency_fullname || bp.project_agency,
|
||||
});
|
||||
}
|
||||
if (bp.department) {
|
||||
institutions.push({
|
||||
label: 'Abteilung',
|
||||
value: bp.department_fullname || bp.department,
|
||||
});
|
||||
}
|
||||
if (bp.division) {
|
||||
institutions.push({ label: 'Division', value: bp.division });
|
||||
}
|
||||
|
||||
return institutions;
|
||||
}
|
||||
|
||||
// searchForLocation(location: string): void {
|
||||
// this.router.navigate(['/bund-projects'], {
|
||||
// queryParams: {
|
||||
// location: location
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// searchForState(state: string): void {
|
||||
// this.router.navigate(['/bund-projects'], {
|
||||
// queryParams: {
|
||||
// state: state
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// searchForFundingType(fundingType: string): void {
|
||||
// this.router.navigate(['/bund-projects'], {
|
||||
// queryParams: {
|
||||
// fundingType: fundingType
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// searchForAgency(agency: string): void {
|
||||
// this.router.navigate(['/bund-projects'], {
|
||||
// queryParams: {
|
||||
// agency: agency
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
searchForInstitutionName(institutionName: string): void {
|
||||
this.router.navigate(['/institutions'], {
|
||||
queryParams: { search: institutionName },
|
||||
});
|
||||
}
|
||||
/**
|
||||
* All associated persons as a simple list.
|
||||
*/
|
||||
@@ -103,13 +111,6 @@ export class BundDetailsComponent implements OnInit {
|
||||
return this.bundProject?.associated_persons || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* All institutions as a simple list.
|
||||
*/
|
||||
getInstitutions(): string[] {
|
||||
return this.bundProject?.institutions || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if project is new
|
||||
*/
|
||||
|
||||
@@ -77,15 +77,6 @@
|
||||
<span>Status</span>
|
||||
</div>
|
||||
</div>
|
||||
@if (getSubjectArea()) {
|
||||
<div class="metric-item">
|
||||
<mat-icon>category</mat-icon>
|
||||
<div class="metric-content">
|
||||
<strong>{{ getSubjectArea() }}</strong>
|
||||
<span>Fachliche Zuordnung</span>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if (dfgProject.dfg_procedure) {
|
||||
<div class="metric-item">
|
||||
<mat-icon>gavel</mat-icon>
|
||||
@@ -137,7 +128,49 @@
|
||||
<p class="description-text">{{ getFinalReportAbstract() }}</p>
|
||||
</mat-card>
|
||||
}
|
||||
|
||||
<!-- OpenAlex Topics -->
|
||||
@if (dfgProject.topics && dfgProject.topics.length > 0) {
|
||||
<app-project-oa-topics
|
||||
[topics]="dfgProject.topics"></app-project-oa-topics>
|
||||
}
|
||||
<!-- Fachsystematik -->
|
||||
@if (getSubjectClassifications().length > 0) {
|
||||
<mat-card appearance="outlined" class="card">
|
||||
<div class="section-header">
|
||||
<mat-icon>category</mat-icon>
|
||||
<h2>Fachsystematik</h2>
|
||||
<span class="count-badge">{{
|
||||
getSubjectClassifications().length
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="classification-list">
|
||||
@for (entry of getSubjectClassifications(); track $index) {
|
||||
<div class="classification-path">
|
||||
@for (
|
||||
segment of getClassificationParentSegments(entry);
|
||||
track $index
|
||||
) {
|
||||
<span class="classification-segment">{{ segment }}</span>
|
||||
<mat-icon class="classification-separator"
|
||||
>chevron_right</mat-icon
|
||||
>
|
||||
}
|
||||
<div class="classification-leaf-group">
|
||||
@for (
|
||||
leaf of getClassificationLeafSegments(entry);
|
||||
track $index
|
||||
) {
|
||||
<span
|
||||
class="classification-segment classification-segment--leaf">
|
||||
{{ leaf }}
|
||||
</span>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</mat-card>
|
||||
}
|
||||
<!-- Beteiligte Personen -->
|
||||
<mat-card appearance="outlined" class="card">
|
||||
<div class="section-header">
|
||||
@@ -175,11 +208,6 @@
|
||||
<div class="empty-state">Keine Personen gefunden.</div>
|
||||
}
|
||||
</mat-card>
|
||||
<!-- OpenAlex Topics -->
|
||||
@if (dfgProject.topics && dfgProject.topics.length > 0) {
|
||||
<app-project-oa-topics
|
||||
[topics]="dfgProject.topics"></app-project-oa-topics>
|
||||
}
|
||||
|
||||
<!-- Beteiligte Institutionen -->
|
||||
<mat-card appearance="outlined" class="card">
|
||||
@@ -336,18 +364,7 @@
|
||||
<dt>Fachliche Zuordnung</dt>
|
||||
<dd>{{ getSubjectArea() || 'N/A' }}</dd>
|
||||
</div>
|
||||
@if (getSubjectClassifications().length > 0) {
|
||||
<div class="detail-row">
|
||||
<dt>Fachsystematik</dt>
|
||||
<dd>
|
||||
@for (entry of getSubjectClassifications(); track $index) {
|
||||
<div class="classification-path">
|
||||
{{ formatSubjectClassification(entry) }}
|
||||
</div>
|
||||
}
|
||||
</dd>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="detail-row">
|
||||
<dt>DFG-Verfahren</dt>
|
||||
<dd>{{ dfgProject.dfg_procedure || 'N/A' }}</dd>
|
||||
|
||||
@@ -154,7 +154,7 @@ h1 {
|
||||
|
||||
.metrics-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
gap: 16px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid var(--sg-border);
|
||||
@@ -473,10 +473,54 @@ h1 {
|
||||
color: var(--sg-text-muted);
|
||||
}
|
||||
|
||||
.classification-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
padding: 16px 20px 20px;
|
||||
}
|
||||
|
||||
.classification-path {
|
||||
font-size: 13px;
|
||||
color: var(--sg-text);
|
||||
line-height: 1.5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px 2px;
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: var(--sg-radius-sm);
|
||||
background: var(--sg-surface);
|
||||
}
|
||||
|
||||
.classification-segment {
|
||||
font-size: 12px;
|
||||
line-height: 1.3;
|
||||
padding: 3px 10px;
|
||||
border-radius: 10px;
|
||||
background: var(--sg-surface-soft);
|
||||
color: var(--sg-text-muted);
|
||||
white-space: nowrap;
|
||||
|
||||
&--leaf {
|
||||
background: var(--sg-primary-soft);
|
||||
color: var(--sg-text);
|
||||
font-weight: 500;
|
||||
white-space: normal;
|
||||
}
|
||||
}
|
||||
|
||||
.classification-leaf-group {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.classification-separator {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
font-size: 16px;
|
||||
color: var(--sg-text-muted);
|
||||
flex-shrink: 0;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.website-html {
|
||||
|
||||
@@ -8,13 +8,9 @@ import { DfgProjectPublicationSummary } from '../../../api/model/dfgProjectPubli
|
||||
import { DfgProjectSubprojectSummary } from '../../../api/model/dfgProjectSubprojectSummary';
|
||||
import { DfgProjectInstitutionRole } from '../../../api/model/dfgProjectInstitutionRole';
|
||||
import { DfgProjectPersonRole } from '../../../api/model/dfgProjectPersonRole';
|
||||
import { DfgProjectSubjectArea } from '../../../api/model/dfgProjectSubjectArea';
|
||||
import { DFGProjectFachgebieteInner } from '../../../api/model/dFGProjectFachgebieteInner';
|
||||
import { ProjectOaTopicsComponent } from '../../../shared/ui/project-oa-topics/project-oa-topics.component';
|
||||
import { Topic } from '../../../api';
|
||||
import {
|
||||
topicHierarchyColor,
|
||||
TopicHierarchyColorInput,
|
||||
} from '../../../resolvers/utils/topic-colors';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dfg-details',
|
||||
standalone: true,
|
||||
@@ -159,22 +155,26 @@ export class DfgDetailsComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
// --- Subject classification (DFG Fachsystematik) ---
|
||||
//(DFG Fachsystematik)
|
||||
|
||||
getSubjectClassifications(): DfgProjectSubjectArea[] {
|
||||
getSubjectClassifications(): DFGProjectFachgebieteInner[] {
|
||||
return this.dfgProject?.subject_classifications ?? [];
|
||||
}
|
||||
|
||||
/** Renders one classification entry as a breadcrumb-like path. */
|
||||
formatSubjectClassification(entry: DfgProjectSubjectArea): string {
|
||||
getClassificationParentSegments(entry: DFGProjectFachgebieteInner): string[] {
|
||||
return [
|
||||
entry.wissenschaftsbereich,
|
||||
entry.fachkollegium,
|
||||
entry.fachgebiet,
|
||||
entry.fach,
|
||||
]
|
||||
.filter((part) => !!part)
|
||||
.join(' › ');
|
||||
].filter((part): part is string => !!part);
|
||||
}
|
||||
|
||||
getClassificationLeafSegments(entry: DFGProjectFachgebieteInner): string[] {
|
||||
if (!entry.fach) return [];
|
||||
return entry.fach
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter((s) => !!s);
|
||||
}
|
||||
|
||||
// --- Subprojects & publications ---
|
||||
|
||||
+4
-8
@@ -33,15 +33,11 @@
|
||||
{{ org.city }}
|
||||
|
||||
@if (org.country) {
|
||||
<img
|
||||
alt=""
|
||||
<app-country-flag
|
||||
class="country-flag"
|
||||
[src]="
|
||||
'https://flagcdn.io/' +
|
||||
getSvgByCountryCode(org.country) +
|
||||
'.svg'
|
||||
"
|
||||
height="10" />
|
||||
[countryCode]="org.country"
|
||||
[height]="10"
|
||||
[bordered]="false" />
|
||||
}
|
||||
</span>
|
||||
} @else {
|
||||
|
||||
+2
-14
@@ -19,6 +19,7 @@ import {
|
||||
DataTableComponent,
|
||||
GenericColumn,
|
||||
} from '../../../../shared/ui/data-table/data-table.component';
|
||||
import { CountryFlagComponent } from '../../../../shared/ui/country-flag/country-flag.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-organizations-table',
|
||||
@@ -29,6 +30,7 @@ import {
|
||||
CurrencyPipe,
|
||||
DataTableComponent,
|
||||
MatPaginatorModule,
|
||||
CountryFlagComponent,
|
||||
],
|
||||
templateUrl: './organizations-table.component.html',
|
||||
styleUrl: './organizations-table.component.scss',
|
||||
@@ -128,20 +130,6 @@ export class OrganizationsTableComponent {
|
||||
this.pageSize.set(event.pageSize);
|
||||
}
|
||||
|
||||
getSvgByCountryCode(code: string | undefined | null): string {
|
||||
if (!code) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const codeLower = code.toLowerCase();
|
||||
|
||||
if (codeLower === 'uk') {
|
||||
return 'gb';
|
||||
}
|
||||
|
||||
return codeLower;
|
||||
}
|
||||
|
||||
getOrgsCount(): number {
|
||||
return this.orgs?.length || 0;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
</button>
|
||||
|
||||
@if (loading) {
|
||||
<div class="state">
|
||||
<mat-spinner diameter="42"></mat-spinner>
|
||||
<p>Publikation wird geladen...</p>
|
||||
</div>
|
||||
<app-loading
|
||||
text="Publikation wird geladen..."
|
||||
icon="menu_book"
|
||||
[size]="60"
|
||||
[diameter]="60" />
|
||||
} @else if (notFound || !publication) {
|
||||
<div class="state error-state">
|
||||
<mat-icon>search_off</mat-icon>
|
||||
@@ -409,15 +410,10 @@
|
||||
</a>
|
||||
@if (institution.country) {
|
||||
<span class="institution-country">
|
||||
<img
|
||||
alt=""
|
||||
class="flag-img"
|
||||
[src]="
|
||||
'https://flagcdn.io/' +
|
||||
institution.country.toLowerCase() +
|
||||
'.svg'
|
||||
"
|
||||
height="14" />
|
||||
<app-country-flag
|
||||
[countryCode]="institution.country"
|
||||
[height]="14"
|
||||
[rounded]="true" />
|
||||
{{ institution.country.toUpperCase() }}
|
||||
</span>
|
||||
} @else if (institution.type) {
|
||||
|
||||
@@ -491,11 +491,6 @@ dd {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.institution-country .flag-img {
|
||||
border: 1px solid var(--sg-border);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.link-list a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -5,7 +5,6 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { ActivatedRoute, Router, RouterLink } from '@angular/router';
|
||||
import {
|
||||
@@ -17,6 +16,8 @@ import {
|
||||
WorkClassification,
|
||||
} from '../../api';
|
||||
import { TopicChipComponent } from '../../shared/ui/topic-chip/topic-chip.component';
|
||||
import { CountryFlagComponent } from '../../shared/ui/country-flag/country-flag.component';
|
||||
import { LoadingComponent } from '../../shared/ui/loading/loading.component';
|
||||
import { topicHierarchyColor } from '../../resolvers/utils/topic-colors';
|
||||
import { WorkTypePipe } from '../../shared/pipes/work-type.pipe';
|
||||
import { LanguageCodePipe } from '../../shared/pipes/language-code.pipe';
|
||||
@@ -42,7 +43,6 @@ interface InstitutionDetail {
|
||||
DecimalPipe,
|
||||
MatButtonModule,
|
||||
MatIconModule,
|
||||
MatProgressSpinnerModule,
|
||||
MatTooltipModule,
|
||||
RouterLink,
|
||||
TopicChipComponent,
|
||||
@@ -50,6 +50,8 @@ interface InstitutionDetail {
|
||||
LanguageCodePipe,
|
||||
WorkPrimaryCategoryPipe,
|
||||
ResearchProfileComponent,
|
||||
CountryFlagComponent,
|
||||
LoadingComponent,
|
||||
],
|
||||
templateUrl: './publication-detail.component.html',
|
||||
styleUrl: './publication-detail.component.scss',
|
||||
|
||||
@@ -45,10 +45,11 @@
|
||||
</div>
|
||||
}
|
||||
@if (loading()) {
|
||||
<div class="loading-state">
|
||||
<mat-spinner diameter="24"></mat-spinner>
|
||||
<span>Lade Themen...</span>
|
||||
</div>
|
||||
<app-loading
|
||||
text="Lade Themen..."
|
||||
icon="folder_open"
|
||||
[size]="48"
|
||||
[diameter]="48" />
|
||||
} @else {
|
||||
@if (searchQuery()) {
|
||||
<!-- Flat Search Results Mode -->
|
||||
|
||||
@@ -11,16 +11,6 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 8px;
|
||||
padding: 16px;
|
||||
color: var(--sg-text-muted);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Flat Search Results Styles */
|
||||
.search-results {
|
||||
display: flex;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user