Pagination for comments

This commit is contained in:
Matej Focko 2019-11-23 13:46:37 +01:00
parent 6c53c3cdea
commit 8e7648ce5a

View file

@ -69,8 +69,8 @@ def set_assignees(iid, assignee_ids):
print(req.status_code) print(req.status_code)
def get_comments(iid): def get_comments(iid, page=1):
params = {"sort": "asc"} params = {"sort": "asc", "page": page}
headers = {"Private-Token": TOKEN} headers = {"Private-Token": TOKEN}
with requests.get( with requests.get(
@ -78,4 +78,8 @@ def get_comments(iid):
params=params, params=params,
headers=headers, headers=headers,
) as req: ) as req:
return req.json() comments = req.json()
if 'rel="next"' in req.headers["Link"]:
comments.extend(get_comments(iid, page + 1))
return comments