Skip to content

Commit 93d192f

Browse files
authored
Add support for indicating the pagination direction in the ListPage objects (#61)
1 parent 63e7f94 commit 93d192f

File tree

4 files changed

+6
-0
lines changed

4 files changed

+6
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Changelog
77
### Added
88

99
- added the `test()` method to the webhook client
10+
- added support for indicating the pagination direction in the `ListPage` objects
1011

1112
[0.2.0](../../releases/tag/v0.2.0) - 2021-08-09
1213
-----------------------------------------------

docs/docs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2838,6 +2838,7 @@ Name | Type | Description
28382838
`limit` | `int` | The offset of the first object specified in the API call
28392839
`count` | `int` | Count of the returned objects on this page
28402840
`total` | `int` | Total number of objects matching the API call criteria
2841+
`desc` | `bool` | Whether the listing is descending or not
28412842

28422843
***
28432844

src/apify_client/_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@ class ListPage:
216216
limit: int
217217
#: int: Total number of objects matching the API call criteria
218218
total: int
219+
#: bool: Whether the listing is descending or not
220+
desc: bool
219221

220222
def __init__(self, data: Dict) -> None:
221223
"""Initialize a ListPage instance from the API response data."""
@@ -224,3 +226,4 @@ def __init__(self, data: Dict) -> None:
224226
self.limit = data['limit'] if 'limit' in data else 0
225227
self.count = data['count'] if 'count' in data else len(self.items)
226228
self.total = data['total'] if 'total' in data else self.offset + self.count
229+
self.desc = data['desc'] if 'desc' in data else False

src/apify_client/clients/resource_clients/dataset.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def list_items(
116116
'offset': int(response.headers['x-apify-pagination-offset']),
117117
'count': len(data), # because x-apify-pagination-count returns invalid values when hidden/empty items are skipped
118118
'limit': int(response.headers['x-apify-pagination-limit']), # API returns 999999999999 when no limit is used
119+
'desc': bool(response.headers['x-apify-pagination-desc']),
119120
})
120121

121122
def iterate_items(

0 commit comments

Comments
 (0)