Skip to content

Commit cd6b737

Browse files
committed
get_job: ensure pagination is supported
1 parent 22e38f7 commit cd6b737

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

memsource/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,13 @@ def get_jobs(self, project_id, filters=None):
200200

201201
try:
202202
jobs = self.handle_rest_call(url, "GET").json()["content"]
203+
total_pages = self.handle_rest_call(url, "GET").json()["totalPages"]
204+
i = 1
205+
while i <= total_pages:
206+
next_page_url = f"{url}/?pageNumber={i}"
207+
next_page_jobs = self.handle_rest_call(next_page_url, "GET").json()["content"]
208+
jobs.extend(next_page_jobs)
209+
i += 1
203210
return jobs if not filters else [item for item in jobs if filters.items() <= item.items()]
204211
except Exception as exc:
205212
raise exc

0 commit comments

Comments
 (0)