File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,8 @@ def __iter__(self):
20
20
21
21
def __next__ (self ):
22
22
if not self .values :
23
- self .values , self .next = self .next ()
23
+ if self .next :
24
+ self .values , self .next = self .next ()
24
25
if not self .values :
25
26
raise StopIteration
26
27
return self .values .pop (0 )
@@ -61,18 +62,18 @@ def _find_tasks_paged(self, **kwargs):
61
62
:key str org: filter tasks to a specific organization name
62
63
:key str org_id: filter tasks to a specific organization ID
63
64
:key int limit: the number of tasks to return in one page
64
- :return: Tasks, Next
65
+ :return: Tasks, Next or None
65
66
"""
66
- tasks = self ._service .get_tasks (** kwargs ).tasks
67
+ tasks_response = self ._service .get_tasks (** kwargs )
68
+ tasks = tasks_response .tasks
67
69
70
+ has_next = tasks_response .links .next is not None
68
71
last_id = tasks [- 1 ].id if tasks else None
69
72
def next ():
70
- if last_id is not None :
73
+ if has_next and last_id is not None :
71
74
return self ._find_tasks_paged (** {** kwargs , 'after' : last_id })
72
75
else :
73
- def func ():
74
- raise Exception ("There are no additional pages remaining for tasks." )
75
- return [], func
76
+ return [], None
76
77
77
78
return tasks , next
78
79
You can’t perform that action at this time.
0 commit comments