8000 Update Pager to handle un-paged lists (#322) · SnarkyPapi/server-client-python@6094eb3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6094eb3

Browse files
authored
Update Pager to handle un-paged lists (tableau#322)
Not all endpoints support pagination on the server-side. We don't really give a way to predict what will or won't work with `Pager`, so I've updated it to check for a `total_available` amount. If that is `None` the endpoint doesn't support paging, and we can just drain the existing list and return. If the endpoint gets updated to support paging, it'll just magically start working.
1 parent 59bf892 commit 6094eb3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tableauserverclient/server/pager.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ def __iter__(self):
3636
# Fetch the first page
3737
current_item_list, last_pagination_item = self._endpoint(self._options)
3838

39+
if last_pagination_item.total_available is None:
40+
# This endpoint does not support pagination, drain the list and return
41+
while current_item_list:
42+
yield current_item_list.pop(0)
43+
44+
return
45+
3946
# Get the rest on demand as a generator
4047
while self._count < last_pagination_item.total_available:
4148
if len(current_item_list) == 0:

0 commit comments

Comments
 (0)
0