Skip to content

Commit b19c60b

Browse files
committed
Add pagination to get_snapshots
1 parent 414dd07 commit b19c60b

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Stable Release Candidate 1
44

5-
10x performance increase when serializing models!
5+
10x performance increase when serializing/deserializing models!
66

77
## Breaking changes
88

@@ -46,6 +46,7 @@ Stable Release Candidate 1
4646
- Added `CompetitionService.get_details_csv` method.
4747
- Added `MetricLeader` class for the different flavors of leader to derive from.
4848
- Added `CompetitionCSVTableType` enum for the competition details csv endpoint.
49+
- Added pagination to `PlayerService.get_snapshots`.
4950

5051
## Changes
5152

@@ -55,7 +56,7 @@ Stable Release Candidate 1
5556
`Bosses`, and `ComputedMetrics` enums.
5657
- `GroupService.create_group` now returns a `CreatedGroupDetail` model.
5758
- Updated docstrings for group classes.
58-
- Fixed broken poetry install link in contriubuting guide.
59+
- Fixed broken poetry install link in contributing guide.
5960

6061
---
6162

wom/services/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _get_request_func(self, method: str) -> t.Callable[..., t.Awaitable[t.Any]]:
109109
if not hasattr(self, "_method_mapping"):
110110
raise RuntimeError("HttpService.start was never called, aborting...")
111111

112-
return self._method_mapping[method] # type: ignore[return-value]
112+
return self._method_mapping[method]
113113

114114
async def _init_session(self) -> None:
115115
self._session = aiohttp.ClientSession(

wom/services/players.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ async def search_players(
5252
5353
Keyword Args:
5454
limit: The maximum number of paginated items to receive.
55-
Defaults to `None` (I think thats 20 items?).
55+
Defaults to `None`.
5656
57-
offset: The page offset for requesting multiple pages.
57+
offset: The page offset for requesting the next page.
5858
Defaults to `None`.
5959
6060
Returns:
@@ -466,6 +466,8 @@ async def get_snapshots(
466466
period: t.Optional[enums.Period] = None,
467467
start_date: t.Optional[datetime] = None,
468468
end_date: t.Optional[datetime] = None,
469+
limit: t.Optional[int] = None,
470+
offset: t.Optional[int] = None,
469471
) -> ResultT[t.List[models.Snapshot]]:
470472
"""Gets the snapshots for the player.
471473
@@ -482,6 +484,12 @@ async def get_snapshots(
482484
end_date: The maximum date to get the snapshots from.
483485
Defaults to `None`.
484486
487+
limit: The maximum number of paginated items to receive.
488+
Defaults to `None`.
489+
490+
offset: The page offset for requesting the next page.
491+
Defaults to `None`.
492+
485493
Returns:
486494
A [`Result`][wom.Result] containing the list of snapshots.
487495
@@ -500,14 +508,16 @@ async def get_snapshots(
500508
await client.start()
501509
502510
result = await client.players.get_snapshots(
503-
"Jonxslays", period=wom.Period.Week
511+
"Jonxslays", period=wom.Period.Week, limit=3
504512
)
505513
```
506514
"""
507515
params = self._generate_map(
508516
period=period.value if period else None,
509517
startDate=start_date.isoformat() if start_date else None,
510518
endDate=end_date.isoformat() if end_date else None,
519+
limit=limit if limit else None,
520+
offset=offset if offset else None,
511521
)
512522

513523
route = routes.PLAYER_SNAPSHOTS.compile(username)

0 commit comments

Comments
 (0)