From 8e7648ce5a424ff33517a06ca5928f4bfda778c8 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Sat, 23 Nov 2019 13:46:37 +0100 Subject: [PATCH] Pagination for comments --- gitlab.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gitlab.py b/gitlab.py index 215ebdd..e4237f2 100644 --- a/gitlab.py +++ b/gitlab.py @@ -69,8 +69,8 @@ def set_assignees(iid, assignee_ids): print(req.status_code) -def get_comments(iid): - params = {"sort": "asc"} +def get_comments(iid, page=1): + params = {"sort": "asc", "page": page} headers = {"Private-Token": TOKEN} with requests.get( @@ -78,4 +78,8 @@ def get_comments(iid): params=params, headers=headers, ) as req: - return req.json() + comments = req.json() + if 'rel="next"' in req.headers["Link"]: + comments.extend(get_comments(iid, page + 1)) + return comments +