Readded missing single work retrieval logic
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -129,6 +129,33 @@ async def get_primary_topic_counts(
|
||||
for item in items
|
||||
]
|
||||
|
||||
|
||||
async def get_work(
|
||||
work_id: str,
|
||||
client: OpenAlexWorksSearchClient | None = None,
|
||||
) -> Work:
|
||||
search_client = client or OpenAlexWorksSearchClient()
|
||||
try:
|
||||
data = await search_client.search_work(work_id)
|
||||
except MissingApiKeyError as exc:
|
||||
raise HTTPException(
|
||||
status_code=HTTP_503_SERVICE_UNAVAILABLE,
|
||||
detail="OpenAlex works search is not configured.",
|
||||
) from exc
|
||||
except httpx.HTTPError as exc:
|
||||
raise HTTPException(
|
||||
status_code=HTTP_502_BAD_GATEWAY,
|
||||
detail="OpenAlex works search request failed.",
|
||||
) from exc
|
||||
elements, _ = _parse_full_work_search_response(data)
|
||||
if not elements:
|
||||
raise HTTPException(
|
||||
status_code=HTTP_404_NOT_FOUND,
|
||||
detail="Publication not found.",
|
||||
)
|
||||
return elements[0]
|
||||
|
||||
|
||||
def _get_topic_descriptions(topic_ids: List[str]) -> dict[str, str]:
|
||||
if not topic_ids:
|
||||
return {}
|
||||
@@ -182,6 +209,7 @@ def _limit_works_by_complete_years(
|
||||
|
||||
return selected_works
|
||||
|
||||
|
||||
async def _get_limited_author_works_by_complete_years(
|
||||
author_id: str,
|
||||
target_publications: int,
|
||||
@@ -416,7 +444,7 @@ def _parse_full_work_search_response(data: dict) -> tuple[list[Work], int]:
|
||||
source_copy["title"] = source_copy["display_name"]
|
||||
elif not source_copy.get("display_name") and source_copy.get("title"):
|
||||
source_copy["display_name"] = source_copy["title"]
|
||||
|
||||
|
||||
# Resilient sanitization of IDs to protect against model regeneration type conflicts
|
||||
ids = source_copy.get("ids")
|
||||
if isinstance(ids, dict):
|
||||
|
||||
-12
@@ -12,18 +12,6 @@
|
||||
{{ element.collaborators.length }}
|
||||
</td>
|
||||
</ng-container>
|
||||
<ng-container matColumnDef="actions">
|
||||
<th mat-header-cell *matHeaderCellDef></th>
|
||||
<td mat-cell *matCellDef="let element">
|
||||
<a
|
||||
mat-icon-button
|
||||
color="primary"
|
||||
[routerLink]="['/institution', element.id]"
|
||||
>
|
||||
<mat-icon>open_in_new</mat-icon>
|
||||
</a>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns; sticky: true"></tr>
|
||||
<tr
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ export class PersonNetworkInstitutionsComponent implements AfterViewInit {
|
||||
collaborationNetwork = input.required<CollaborationNetwork>();
|
||||
searchTerm = input.required<string>();
|
||||
|
||||
displayedColumns: string[] = ['name', 'collaborators', 'actions'];
|
||||
displayedColumns: string[] = ['name', 'collaborators'];
|
||||
|
||||
dataSource = new MatTableDataSource<Institution>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user