Skip to content

Commit

Permalink
got trolled by route order
Browse files Browse the repository at this point in the history
  • Loading branch information
Furrior committed Feb 10, 2025
1 parent 769120b commit 3df06f9
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 55 deletions.
37 changes: 18 additions & 19 deletions app/routes/v1/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,25 +110,6 @@ async def callback(session: SessionDep, code: str, state: str) -> Player:

player_router = APIRouter(prefix="/players", tags=["Player"])


@player_router.get(
"/{id}",
status_code=status.HTTP_200_OK,
responses={
status.HTTP_200_OK: {"description": "Player"},
status.HTTP_404_NOT_FOUND: {"description": "Player not found"},
}
)
async def get_player_by_id(session: SessionDep, id: int) -> Player: # pylint: disable=redefined-builtin
result = session.exec(select(Player).where(Player.id == id)).first()

if result is None:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail="Player not found")

return result


@player_router.get(
"/discord/{discord_id}",
status_code=status.HTTP_200_OK,
Expand Down Expand Up @@ -182,6 +163,24 @@ async def get_players(session: SessionDep, request: Request, page: int = 1, page
)


@player_router.get(
"/{id}",
status_code=status.HTTP_200_OK,
responses={
status.HTTP_200_OK: {"description": "Player"},
status.HTTP_404_NOT_FOUND: {"description": "Player not found"},
}
)
async def get_player_by_id(session: SessionDep, id: int) -> Player: # pylint: disable=redefined-builtin
result = session.exec(select(Player).where(Player.id == id)).first()

if result is None:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND, detail="Player not found")

return result


@player_router.patch("/{id}", status_code=status.HTTP_200_OK, responses=BEARER_DEP_RESPONSES, dependencies=[Depends(verify_bearer)])
async def update_player(session: SessionDep, id: int, player_patch: PlayerPatch) -> Player: # pylint: disable=redefined-builtin
player = await get_player_by_id(session, id)
Expand Down
71 changes: 35 additions & 36 deletions app/routes/v1/whitelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,6 @@ def filter_whitelist_bans(selection: SelectOfScalar[WhitelistBan],
# region Get


@whitelist_router.get("/{id}",
status_code=status.HTTP_200_OK,
responses={
status.HTTP_200_OK: {"description": "Whitelist"},
status.HTTP_404_NOT_FOUND: {"description": "Whitelist not found"},
})
def get_whitelist(session, id): # pylint: disable=redefined-builtin
wl = session.exec(select(Whitelist).where(Whitelist.id == id)).first()

if wl is None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
detail="Whitelist not found")

return wl


@whitelist_router.get("",
status_code=status.HTTP_200_OK,
responses={
Expand All @@ -103,8 +87,7 @@ async def get_whitelists(session: SessionDep,
@whitelist_router.get("/ckeys",
status_code=status.HTTP_200_OK,
responses={
status.HTTP_200_OK: {"description": "Whitelistd ckeys"},
status.HTTP_400_BAD_REQUEST: {"description": "Invalid filter combination"},
status.HTTP_200_OK: {"description": "Whitelisted ckeys"},
})
async def get_whitelisted_ckeys(session: SessionDep,
request: Request,
Expand All @@ -121,6 +104,23 @@ async def get_whitelisted_ckeys(session: SessionDep,

return paginate_selection(session, selection, request, page, page_size)


@whitelist_router.get("/{id}",
status_code=status.HTTP_200_OK,
responses={
status.HTTP_200_OK: {"description": "Whitelist"},
status.HTTP_404_NOT_FOUND: {"description": "Whitelist not found"},
})
def get_whitelist(session: SessionDep,
id: int): # pylint: disable=redefined-builtin
wl = session.exec(select(Whitelist).where(Whitelist.id == id)).first()

if wl is None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
detail="Whitelist not found")

return wl

# endregion
# region Post

Expand Down Expand Up @@ -206,24 +206,6 @@ def select_only_active_whitelist_bans(selection: SelectOfScalar[WhitelistBan]):

# region Get


@whitelist_ban_router.get("/{id}",
status_code=status.HTTP_200_OK,
responses={
status.HTTP_200_OK: {"description": "Whitelist"},
status.HTTP_404_NOT_FOUND: {"description": "Whitelist not found"},
})
def get_whitelist_ban(session, id): # pylint: disable=redefined-builtin
wl_ban = session.exec(select(WhitelistBan).where(
WhitelistBan.id == id)).first()

if wl_ban is None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
detail="Whitelist ban not found")

return wl_ban


@whitelist_ban_router.get("", status_code=status.HTTP_200_OK)
async def get_whitelist_bans(session: SessionDep,
request: Request,
Expand Down Expand Up @@ -252,6 +234,23 @@ async def get_whitelist_bans(session: SessionDep,
current_url=request.url,
)


@whitelist_ban_router.get("/{id}",
status_code=status.HTTP_200_OK,
responses={
status.HTTP_200_OK: {"description": "Whitelist"},
status.HTTP_404_NOT_FOUND: {"description": "Whitelist not found"},
})
def get_whitelist_ban(session, id): # pylint: disable=redefined-builtin
wl_ban = session.exec(select(WhitelistBan).where(
WhitelistBan.id == id)).first()

if wl_ban is None:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND,
detail="Whitelist ban not found")

return wl_ban

# endregion
# region Post

Expand Down

0 comments on commit 3df06f9

Please sign in to comment.