Skip to content
Snippets Groups Projects
Commit b68b4031 authored by Tim Repke's avatar Tim Repke
Browse files

add oa search route

parent 08b81999
No related branches found
No related tags found
1 merge request!53OpenAlex Search and pydantic v2 migration
Pipeline #1852 failed
......@@ -52,7 +52,7 @@ test-job2:
- source venv/bin/activate
- which python
- pip freeze
- python -m mypy --config-file=pyproject.toml server
- python -m mypy --config-file=pyproject.toml server --show-traceback --no-incremental
deploy-to-production:
stage: deploy
......
from fastapi import APIRouter, Depends
from pydantic import BaseModel
from typing import Literal
import httpx
from pydantic import BaseModel
from fastapi import APIRouter, Depends
from nacsos_data.util.academic.openalex import query_async, SearchResult
from server.util.security import UserPermissionChecker, UserPermissions
from server.util.logging import get_logger
......@@ -18,11 +22,23 @@ class TermStats(BaseModel):
ttf: int
@router.get('/openalex', response_model=str)
async def search_openalex(import_id: str,
permissions: UserPermissions = Depends(UserPermissionChecker('search_oa'))):
# u = settings.OA_SOLR
pass
@router.get('/openalex', response_model=SearchResult)
async def search_openalex(query: str,
limit: int = 20,
field: Literal['title', 'abstract', 'title_abstract'] = 'title_abstract',
histogram: bool = False,
op: Literal['OR', 'AND'] = 'AND',
histogram_from: int = 1990,
histogram_to: int = 2024,
permissions: UserPermissions = Depends(UserPermissionChecker('search_oa'))) -> SearchResult:
return await query_async(query=query,
openalex_endpoint=f'{settings.OA_SOLR}/select',
histogram=histogram,
histogram_to=histogram_to,
histogram_from=histogram_from,
op=op,
field=field,
limit=limit)
@router.post('/terms', response_model=list[TermStats])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment