projects data models adjustments
This commit is contained in:
@@ -34,7 +34,7 @@ from typing import Union
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
async def get_dfg_author_names_by_ids(author_ids: List[str]) -> Optional[List[str]]:
|
||||
async def get_dfg_author_names_by_ids(author_ids: List[int]) -> Optional[List[str]]:
|
||||
try:
|
||||
body = {
|
||||
"_source": ["id", "full_name"],
|
||||
@@ -53,7 +53,7 @@ async def get_dfg_author_names_by_ids(author_ids: List[str]) -> Optional[List[st
|
||||
logger.exception(f"Error fetching author names for ids {author_ids}: {str(e)}")
|
||||
return []
|
||||
|
||||
async def get_dfg_institution_names_by_ids(institution_ids: List[str]) -> Optional[List[str]]:
|
||||
async def get_dfg_institution_names_by_ids(institution_ids: List[int]) -> Optional[List[str]]:
|
||||
try:
|
||||
body = {
|
||||
"_source": ["id","institute_name_de","institute_name_en"],
|
||||
|
||||
@@ -12,6 +12,7 @@ from inse.model import ESIndex
|
||||
from inse.models.projects_eu_cordis.horizon2020.h2020_project_details import H2020ProjectDetails
|
||||
from inse.models.projects_eu_cordis.horizon_europe.heu_project_details import HEUProjectDetails
|
||||
from inse.models.projects_eu_cordis.fp7.fp7_project_details import Fp7ProjectDetails
|
||||
from inse.models.projects_dfg_v2.project.dfg_project_fachgebiete_inner import DFGProjectFachgebieteInner
|
||||
from typing import Union
|
||||
|
||||
class ProjectType(StrEnum):
|
||||
@@ -86,17 +87,23 @@ class EuProjectPage(Page):
|
||||
)
|
||||
|
||||
class DfgInstitutionSummary(BaseModel):
|
||||
"""A summary of a DFG institution."""
|
||||
id: int
|
||||
name_de: Optional[str] = None
|
||||
name_en: Optional[str] = None
|
||||
institute_name_de: Optional[str] = None
|
||||
institute_name_en: Optional[str] = None
|
||||
root_id: Optional[int] = None
|
||||
root_name_de: Optional[str] = None
|
||||
root_name_en: Optional[str] = None
|
||||
address_country_de: Optional[str] = None
|
||||
address_country_en: Optional[str] = None
|
||||
|
||||
class DfgPersonSummary(BaseModel):
|
||||
person_id: int
|
||||
project_ref_id: int
|
||||
orcid_id: Optional[str] = None
|
||||
project_ref_id: Optional[int] = None
|
||||
full_name: Optional[str] = None
|
||||
role_label_en: Optional[str] = None,
|
||||
role_label_de: Optional[str] = None,
|
||||
root_institution: Optional[DfgInstitutionSummary] = None,
|
||||
institution: Optional[DfgInstitutionSummary] = None
|
||||
|
||||
|
||||
@@ -132,14 +139,6 @@ class DfgProjectSummary(BaseModel):
|
||||
description="The funding end date of the DFG project."
|
||||
)
|
||||
|
||||
root_institutions: List[DfgInstitutionSummary] = Field(
|
||||
default_factory=list,
|
||||
description=(
|
||||
"Root institutions associated with the project "
|
||||
"(e.g. universities or umbrella organizations)."
|
||||
),
|
||||
)
|
||||
|
||||
institutions: List[DfgInstitutionSummary] = Field(
|
||||
default_factory=list,
|
||||
description="Institutions associated with the project."
|
||||
@@ -152,6 +151,10 @@ class DfgProjectSummary(BaseModel):
|
||||
default_factory=list,
|
||||
description="The persons involved in the DFG project.",
|
||||
)
|
||||
subject_classifications: Optional[List[DFGProjectFachgebieteInner]] = Field(
|
||||
default=None,
|
||||
description="The subject classifications of the DFG project.",
|
||||
)
|
||||
@classmethod
|
||||
def from_hit(cls, hit: dict) -> "DfgProjectSummary":
|
||||
source = hit.get("_source", {})
|
||||
@@ -159,7 +162,6 @@ class DfgProjectSummary(BaseModel):
|
||||
|
||||
names = []
|
||||
institutions = {}
|
||||
root_institutions = {}
|
||||
project_persons = []
|
||||
|
||||
persons = source.get("persons", [])
|
||||
@@ -178,35 +180,29 @@ class DfgProjectSummary(BaseModel):
|
||||
if person.get("institute_id") is not None:
|
||||
institution = DfgInstitutionSummary(
|
||||
id=person["institute_id"],
|
||||
name_de=person.get("institute_name_de"),
|
||||
name_en=person.get("institute_name_en"),
|
||||
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=person["root_id"],
|
||||
root_name_de=person.get("root_name_de"),
|
||||
root_name_en=person.get("root_name_en"),
|
||||
)
|
||||
|
||||
institutions[person["institute_id"]] = institution
|
||||
|
||||
root_institution = None
|
||||
if person.get("root_id") is not None:
|
||||
root_institution = DfgInstitutionSummary(
|
||||
id=person["root_id"],
|
||||
name_de=person.get("root_name_de"),
|
||||
name_en=person.get("root_name_en"),
|
||||
)
|
||||
|
||||
root_institutions[person["root_id"]] = root_institution
|
||||
|
||||
if person.get("person_id") is not None:
|
||||
project_persons.append(
|
||||
DfgPersonSummary(
|
||||
person_id=person["person_id"],
|
||||
project_ref_id=person.get("project_ref_id"),
|
||||
orcid_id=person.get("orcid_id"),
|
||||
full_name=full_name,
|
||||
role_label_en=person.get("role_label_en"),
|
||||
role_label_de=person.get("role_label_de"),
|
||||
root_institution=root_institution,
|
||||
institution=institution,
|
||||
)
|
||||
)
|
||||
|
||||
return cls(
|
||||
id=hit.get("_id", ""),
|
||||
link=source.get("link") or source.get("page_url"),
|
||||
@@ -230,10 +226,10 @@ class DfgProjectSummary(BaseModel):
|
||||
if source.get("funding_end") is not None
|
||||
else None
|
||||
),
|
||||
root_institutions=list(root_institutions.values()),
|
||||
institutions=list(institutions.values()),
|
||||
names=names,
|
||||
persons=project_persons,
|
||||
subject_classifications=[DFGProjectFachgebieteInner.from_dict(cls) for cls in source.get('subject_classifications', [])]
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -625,6 +625,7 @@ async def search_dfg_projects(
|
||||
"subject_area_de",
|
||||
"subject_area_en",
|
||||
"persons",
|
||||
"subject_classifications",
|
||||
],
|
||||
"query": {},
|
||||
}
|
||||
@@ -637,7 +638,7 @@ async def search_dfg_projects(
|
||||
{
|
||||
"multi_match": {
|
||||
"query": topic,
|
||||
"fields": ["title", "title_de", "title_en","abstract_de","abstract_en","subject_area_de","subject_area_en"],
|
||||
"fields": ["title", "title_de", "title_en","abstract_de","abstract_en","subject_area_de","subject_area_en","subject_classifications.fach","subject_classifications.fachkollegium","subject_classifications.fachgebiet,subject_classifications.fachgebiet_de","subject_classifications.wissenschaftsbereich"],
|
||||
"type": "phrase_prefix",
|
||||
"max_expansions": 100,
|
||||
}
|
||||
@@ -665,18 +666,33 @@ async def search_dfg_projects(
|
||||
)
|
||||
if names:
|
||||
name_must_clauses = []
|
||||
|
||||
for full_name in names:
|
||||
full_name = full_name.strip()
|
||||
if not full_name:
|
||||
name_parts = full_name.strip().split()
|
||||
if not name_parts:
|
||||
continue
|
||||
|
||||
match_musts = []
|
||||
|
||||
for part in name_parts:
|
||||
match_musts.append(
|
||||
{
|
||||
"match": {
|
||||
"persons.full_name": {
|
||||
"query": part,
|
||||
"operator": "and",
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
name_must_clauses.append(
|
||||
{
|
||||
"nested": {
|
||||
"path": "persons",
|
||||
"query": {
|
||||
"match_phrase": {
|
||||
"persons.full_name": full_name
|
||||
"bool": {
|
||||
"must": match_musts
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -798,6 +814,10 @@ async def search_dfg_projects(
|
||||
|
||||
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")
|
||||
|
||||
|
||||
|
||||
return _complete_response_to_dfg_project_page(response, page, size)
|
||||
|
||||
@@ -882,6 +902,8 @@ async def get_person_institutes(
|
||||
"root_name_en",
|
||||
"institute_name_de",
|
||||
"institute_name_en",
|
||||
"address_country_de",
|
||||
"address_country_en",
|
||||
],
|
||||
"query": {
|
||||
"terms": {
|
||||
@@ -904,6 +926,8 @@ async def get_person_institutes(
|
||||
"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
|
||||
|
||||
|
||||
@@ -315,9 +315,9 @@ async def get_institution_cordis_eu_projects_funding_over_time(
|
||||
)
|
||||
async def get_dfg_projects(
|
||||
author_id: Annotated[Optional[str], Query(description="The openalex author ID to filter by.")] = None,
|
||||
author_filter_ids: Annotated[Optional[List[str]], Query(description="The author IDs to filter by.")] = None,
|
||||
author_filter_ids: Annotated[Optional[List[int]], Query(description="The author IDs to filter by.")] = None,
|
||||
institution_ids: Annotated[
|
||||
Optional[List[str]], Query(description="The institution IDs to filter by.")
|
||||
Optional[List[int]], Query(description="The institution IDs to filter by.")
|
||||
] = None,
|
||||
title: Annotated[
|
||||
Optional[str], Query(description="The title to filter by.")
|
||||
|
||||
@@ -149,8 +149,8 @@ async def get_cordis_eu_projects_by_institution_id(
|
||||
|
||||
async def get_dfg_projects_by_author_id(
|
||||
author_id: Optional[str],
|
||||
author_filter_ids: Optional[List[str]],
|
||||
institution_ids: Optional[List[str]],
|
||||
author_filter_ids: Optional[List[int]],
|
||||
institution_ids: Optional[List[int]],
|
||||
topics: Optional[List[str]],
|
||||
title: Optional[str],
|
||||
funding_years: Optional[List[str]],
|
||||
|
||||
@@ -8,6 +8,8 @@ api/auth.service.ts
|
||||
api/authorsV2.service.ts
|
||||
api/bookmarks.service.ts
|
||||
api/companyConnections.service.ts
|
||||
api/dFGInstitutions.service.ts
|
||||
api/dFGPersons.service.ts
|
||||
api/dashboard.service.ts
|
||||
api/funding.service.ts
|
||||
api/iNSEService.service.ts
|
||||
@@ -74,6 +76,7 @@ model/createOrganizationRequest.ts
|
||||
model/createPersonBookmark.ts
|
||||
model/customAuthor.ts
|
||||
model/customAuthorsListResponse.ts
|
||||
model/dFGProjectFachgebieteInner.ts
|
||||
model/dashboardStatisticValue.ts
|
||||
model/dashboardStatistics.ts
|
||||
model/dehydratedAuthor.ts
|
||||
@@ -81,7 +84,9 @@ model/dehydratedFunder.ts
|
||||
model/dehydratedInstitution.ts
|
||||
model/dehydratedSource.ts
|
||||
model/dfgInstitutionSummary.ts
|
||||
model/dfgInstitutionSummaryPage.ts
|
||||
model/dfgPersonSummary.ts
|
||||
model/dfgPersonSummaryPage.ts
|
||||
model/dfgProjectDetails.ts
|
||||
model/dfgProjectPage.ts
|
||||
model/dfgProjectSummary.ts
|
||||
|
||||
@@ -6,6 +6,10 @@ export * from './bookmarks.service';
|
||||
import { BookmarksService } from './bookmarks.service';
|
||||
export * from './companyConnections.service';
|
||||
import { CompanyConnectionsService } from './companyConnections.service';
|
||||
export * from './dFGInstitutions.service';
|
||||
import { DFGInstitutionsService } from './dFGInstitutions.service';
|
||||
export * from './dFGPersons.service';
|
||||
import { DFGPersonsService } from './dFGPersons.service';
|
||||
export * from './dashboard.service';
|
||||
import { DashboardService } from './dashboard.service';
|
||||
export * from './funding.service';
|
||||
@@ -40,4 +44,4 @@ export * from './works.service';
|
||||
import { WorksService } from './works.service';
|
||||
export * from './worksV2.service';
|
||||
import { WorksV2Service } from './worksV2.service';
|
||||
export const APIS = [AuthService, AuthorsV2Service, BookmarksService, CompanyConnectionsService, DashboardService, FundingService, INSEServiceService, InstitutionsService, InstitutionsV2Service, KeywordsService, NewsService, OrganizationService, PatentsService, PersonNetworkService, PersonsService, ProjectsService, TopicsService, TopicsV2Service, UniversityRankingsService, WorksService, WorksV2Service];
|
||||
export const APIS = [AuthService, AuthorsV2Service, BookmarksService, CompanyConnectionsService, DFGInstitutionsService, DFGPersonsService, DashboardService, FundingService, INSEServiceService, InstitutionsService, InstitutionsV2Service, KeywordsService, NewsService, OrganizationService, PatentsService, PersonNetworkService, PersonsService, ProjectsService, TopicsService, TopicsV2Service, UniversityRankingsService, WorksService, WorksV2Service];
|
||||
|
||||
@@ -43,6 +43,7 @@ export * from './createOrganizationRequest';
|
||||
export * from './createPersonBookmark';
|
||||
export * from './customAuthor';
|
||||
export * from './customAuthorsListResponse';
|
||||
export * from './dFGProjectFachgebieteInner';
|
||||
export * from './dashboardStatisticValue';
|
||||
export * from './dashboardStatistics';
|
||||
export * from './dehydratedAuthor';
|
||||
@@ -50,7 +51,9 @@ export * from './dehydratedFunder';
|
||||
export * from './dehydratedInstitution';
|
||||
export * from './dehydratedSource';
|
||||
export * from './dfgInstitutionSummary';
|
||||
export * from './dfgInstitutionSummaryPage';
|
||||
export * from './dfgPersonSummary';
|
||||
export * from './dfgPersonSummaryPage';
|
||||
export * from './dfgProjectDetails';
|
||||
export * from './dfgProjectPage';
|
||||
export * from './dfgProjectSummary';
|
||||
|
||||
Reference in New Issue
Block a user