Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
raimannma committed Nov 23, 2024
1 parent 91f7531 commit 87a3b9d
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 154 deletions.
168 changes: 84 additions & 84 deletions deadlock_analytics_api/routers/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,25 +329,11 @@ def match_ranked_subrank(self) -> int | None:
)


@router.get(
"/players/{account_id}/card-history",
summary="RateLimit: 10req/s & 1000req/10min, API-Key RateLimit: 10req/s",
)
def get_player_card_history_single(
req: Request,
res: Response,
account_id: Annotated[
int, Path(description="The account id of the player, it's a SteamID3")
],
) -> list[PlayerCardHistoryEntry]:
return get_player_card_history(req, res, account_ids=str(account_id))[0]


@router.get(
"/players/card-history",
summary="RateLimit: 100req/s",
)
def get_player_card_history(
def get_player_card_history_batch(
req: Request,
res: Response,
account_ids: Annotated[
Expand Down Expand Up @@ -413,25 +399,11 @@ def match_ranked_subrank(self) -> int | None:
)


@router.get(
"/players/{account_id}/mmr-history",
summary="RateLimit: 10req/s & 1000req/10min, API-Key RateLimit: 100req/s & 10000req/10min",
)
def get_player_mmr_history_single(
req: Request,
res: Response,
account_id: Annotated[
int, Path(description="The account id of the player, it's a SteamID3")
],
) -> list[PlayerMMRHistoryEntryV2]:
return get_player_mmr_history(req, res, account_ids=str(account_id))[0]


@router.get(
"/players/mmr-history",
summary="RateLimit: 100req/s",
)
def get_player_mmr_history(
def get_player_mmr_history_batch(
req: Request,
res: Response,
account_ids: Annotated[
Expand Down Expand Up @@ -517,32 +489,6 @@ def highest_ranked_subrank(self) -> int | None:
)


@router.get(
"/players/{account_id}/hero-stats",
summary="RateLimit: 100req/s",
)
def get_player_hero_stats(
req: Request,
res: Response,
account_id: Annotated[
int, Path(description="The account id of the player, it's a SteamID3")
],
hero_id: int | None = None,
min_unix_timestamp: Annotated[int | None, Query(ge=0)] = None,
max_unix_timestamp: int | None = None,
match_mode: Literal["Ranked", "Unranked"] | None = None,
) -> list[PlayerHeroStat]:
return get_player_hero_stats_batch(
req,
res,
account_ids=str(account_id),
hero_id=hero_id,
min_unix_timestamp=min_unix_timestamp,
max_unix_timestamp=max_unix_timestamp,
match_mode=match_mode,
)[account_id]


@router.get(
"/players/hero-stats",
summary="RateLimit: 100req/s",
Expand Down Expand Up @@ -634,34 +580,6 @@ class PlayerItemStat(BaseModel):
matches: int


@router.get(
"/players/{account_id}/item-stats",
summary="RateLimit: 100req/s",
)
def get_player_item_stats(
req: Request,
res: Response,
account_id: Annotated[
int, Path(description="The account id of the player, it's a SteamID3")
],
hero_id: int | None = None,
item_id: int | None = None,
min_unix_timestamp: Annotated[int | None, Query(ge=0)] = None,
max_unix_timestamp: int | None = None,
match_mode: Literal["Ranked", "Unranked"] | None = None,
) -> list[PlayerItemStat]:
return get_player_item_stats_batch(
req,
res,
account_ids=str(account_id),
hero_id=hero_id,
item_id=item_id,
min_unix_timestamp=min_unix_timestamp,
max_unix_timestamp=max_unix_timestamp,
match_mode=match_mode,
)[account_id]


@router.get(
"/players/item-stats",
summary="RateLimit: 100req/s",
Expand Down Expand Up @@ -735,6 +653,88 @@ def get_player_item_stats_batch(
}


@router.get(
"/players/{account_id}/card-history",
summary="RateLimit: 100req/s",
)
def get_player_card_history(
req: Request,
res: Response,
account_id: Annotated[
int, Path(description="The account id of the player, it's a SteamID3")
],
) -> list[PlayerCardHistoryEntry]:
return get_player_card_history_batch(req, res, account_ids=str(account_id))[0]


@router.get(
"/players/{account_id}/item-stats",
summary="RateLimit: 100req/s",
)
def get_player_item_stats(
req: Request,
res: Response,
account_id: Annotated[
int, Path(description="The account id of the player, it's a SteamID3")
],
hero_id: int | None = None,
item_id: int | None = None,
min_unix_timestamp: Annotated[int | None, Query(ge=0)] = None,
max_unix_timestamp: int | None = None,
match_mode: Literal["Ranked", "Unranked"] | None = None,
) -> list[PlayerItemStat]:
return get_player_item_stats_batch(
req,
res,
account_ids=str(account_id),
hero_id=hero_id,
item_id=item_id,
min_unix_timestamp=min_unix_timestamp,
max_unix_timestamp=max_unix_timestamp,
match_mode=match_mode,
)[account_id]


@router.get(
"/players/{account_id}/hero-stats",
summary="RateLimit: 100req/s",
)
def get_player_hero_stats(
req: Request,
res: Response,
account_id: Annotated[
int, Path(description="The account id of the player, it's a SteamID3")
],
hero_id: int | None = None,
min_unix_timestamp: Annotated[int | None, Query(ge=0)] = None,
max_unix_timestamp: int | None = None,
match_mode: Literal["Ranked", "Unranked"] | None = None,
) -> list[PlayerHeroStat]:
return get_player_hero_stats_batch(
req,
res,
account_ids=str(account_id),
hero_id=hero_id,
min_unix_timestamp=min_unix_timestamp,
max_unix_timestamp=max_unix_timestamp,
match_mode=match_mode,
)[account_id]


@router.get(
"/players/{account_id}/mmr-history",
summary="RateLimit: 100req/s",
)
def get_player_mmr_history(
req: Request,
res: Response,
account_id: Annotated[
int, Path(description="The account id of the player, it's a SteamID3")
],
) -> list[PlayerMMRHistoryEntryV2]:
return get_player_mmr_history_batch(req, res, account_ids=str(account_id))[0]


class PlayerMate(BaseModel):
mate_id: int = Field(description="The account id of the mate, it's a SteamID3")
wins: int
Expand Down
Loading

0 comments on commit 87a3b9d

Please sign in to comment.