Skip to content

Commit

Permalink
🐛 person api and affiliation api missing update origin to new services
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon3640 committed Apr 24, 2024
1 parent 638d100 commit c60254d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
15 changes: 6 additions & 9 deletions app/api/routes/v1/affiliation_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from flask import Blueprint, request, Response, Request

from services.v1.affiliation_api import affiliation_api_service
from services.work import work_service
from utils.encoder import JsonEncoder

router = Blueprint("affiliation_api_v1", __name__)
Expand All @@ -15,6 +16,7 @@ def affiliation(
idx: str | None = None,
section: str | None = "info",
tab: str | None = None,
typ: str | None = None
) -> dict[str, Any] | None:
result = None
if section == "info":
Expand All @@ -30,17 +32,12 @@ def affiliation(
page = request.args.get("page")
max_results = request.args.get("max")
sort = request.args.get("sort")
result = affiliation_api_service.get_production(
idx=idx,
start_year=start_year,
end_year=end_year,
page=page,
max_results=max_results,
sort=sort,
result = work_service.get_research_products_info_by_affiliation_csv(
affiliation_id=idx, affiliation_type=typ
)
else:
result = None
return result
return {"data": result, "count": len(result)}


@router.route("/<typ>/<id>", methods=["GET"])
Expand All @@ -52,7 +49,7 @@ def api_affiliation(
tab: str | None = None,
typ: str | None = None,
):
result = affiliation(request, idx=id, section=section, tab=tab)
result = affiliation(request, idx=id, section=section, tab=tab, typ=typ)
if result:
response = Response(
response=json.dumps(result, cls=JsonEncoder),
Expand Down
21 changes: 7 additions & 14 deletions app/api/routes/v1/person_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,25 @@
from flask import Blueprint, request, Response

from services.v1.person_api import person_api_service
from services.work import work_service
from utils.encoder import JsonEncoder

router = Blueprint("person_api_v1", __name__)


@router.route("/<id>", methods=["GET"])
def get_person(id: str | None):
data = request.args.get("data")
@router.route("/<id>/<section>/<tab>", methods=["GET"])
def get_person(id: str | None, section: str | None, tab: str | None):

if data == "info":
if section == "info":
result = person_api_service.get_info(id)
elif data == "production":
elif section == "research" and tab == "products":
max_results = request.args.get("max")
page = request.args.get("page")
start_year = request.args.get("start_year")
end_year = request.args.get("end_year")
sort = request.args.get("sort")
result = person_api_service.get_production(
idx=id,
max_results=max_results,
page=page,
start_year=start_year,
end_year=end_year,
sort=sort,
direction="ascending",
)
works = work_service.get_research_products_by_author_csv(author_id=id)
result = {"data": works, "count": len(works)}
else:
result = None

Expand Down

0 comments on commit c60254d

Please sign in to comment.