diff --git a/src/api/versions/v2.py b/src/api/versions/v2.py index 6f7fb7cc..de8a5857 100644 --- a/src/api/versions/v2.py +++ b/src/api/versions/v2.py @@ -16,10 +16,7 @@ from src.db.connection import Session from src.api.utils.error import check_entity_not_found from src.api.utils.party_sort import party_sort -from src.api.utils.polls import ( - get_politcian_ids_by_bundestag_polldata_and_follow_ids, - get_politcian_ids_by_euparl_polldata_and_follow_ids, -) +from src.api.utils.polls import get_politcian_ids_by_bundestag_polldata_and_follow_ids from src.redis_cache.cache import ONE_DAY_IN_SECONDS, ONE_WEEK_IN_SECONDS, custom_cache router = APIRouter( @@ -269,7 +266,7 @@ def read_politician_sidejobs(db: Session = Depends(get_db)): def read_latest_polls( follow_ids: List[int] = Query(None), db: Session = Depends(get_db) ): - polls = crud.get_polls_total(db, parliament=schemas.Parliament.BUNDESTAG) + polls = crud.get_polls_total(db) latest_polls = get_politcian_ids_by_bundestag_polldata_and_follow_ids( polls, db, follow_ids ) @@ -284,9 +281,7 @@ def read_latest_polls( page: int = Query(1), ): size = page * 10 - filtered_polls = crud.get_all_polls_total( - db, schemas.Parliament.BUNDESTAG, size, filters - ) + filtered_polls = crud.get_all_polls_total(db, size, filters) polls = {} polls["data"] = get_politcian_ids_by_bundestag_polldata_and_follow_ids( filtered_polls, db @@ -299,41 +294,6 @@ def read_latest_polls( return polls -@router.get("/eu/polls", response_model=List[schemas.BundestagPollDataWithPoliticians]) -def read_latest_polls( - follow_ids: List[int] = Query(None), db: Session = Depends(get_db) -): - polls = crud.get_polls_total(db, parliament=schemas.Parliament.EUPARL) - print(polls) - latest_polls = get_politcian_ids_by_euparl_polldata_and_follow_ids( - polls, db, follow_ids - ) - check_entity_not_found(latest_polls, "Polls") - return latest_polls - - -@router.get("/eu/allpolls", response_model=schemas.BundestagPoll) -def read_latest_polls( - filters: List[int] = Query(None), - db: Session = Depends(get_db), - page: int = Query(1), -): - size = page * 10 - filtered_polls = crud.get_all_polls_total( - db, schemas.Parliament.EUPARL, size, filters - ) - polls = {} - polls["data"] = get_politcian_ids_by_euparl_polldata_and_follow_ids( - filtered_polls, db - ) - if len(polls["data"]) < 10: - polls["last_page"] = True - else: - polls["last_page"] = False - check_entity_not_found(polls, "Polls") - return polls - - @router.get("/politician/{id}/news", response_model=Page[schemas.PolitrackNewsArticle]) @custom_cache(expire=ONE_WEEK_IN_SECONDS) async def read_politician_news(id: int):