Use GitHub API pagination to do multiple requests if required.
Tested with some PRs that have a large number of comments.
For issue #15816
Use GitHub API pagination to do multiple requests if required.
Tested with some PRs that have a large number of comments.
For issue #15816
69 | + return json.load(reader(get_response(req_url, ghtoken))) 70 | + 71 | + obj = [] 72 | + page_num = 1 73 | + while True: 74 | + req_url_page = '%s?page=%d' % (req_url, page_num)
Style-nit: Could use str.format
req_url_page = '{}?page={}'.format(req_url, page_num)
75 | + result = get_response(req_url_page, ghtoken) 76 | + obj.extend(json.load(reader(result))) 77 | + 78 | + link = result.headers.get('link', None) 79 | + if link is not None: 80 | + links = link.split(',')
style-nit: Could filter right here and get rid of the found bool?
link_next = [l for l in link.split(',') if 'rel="next"' in l]
I rembered the bool was to avoid going through the whole list but I changed it anyway.
79 | + if link is not None: 80 | + links = link.split(',') 81 | + found = False 82 | + for link in links: 83 | + if 'rel="next"' in link: 84 | + page_num = int(link[link.find("page=") + 5])
comment: Doesn't work for double-digit page numbers, but fine
utACK , feel free to ignore the comments
utACK 942ff2054b41fe3f78f1b3d88cfd032bc95fd62f
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
No conflicts as of last run.
utACK 942ff2054b41fe3f78f1b3d88cfd032bc95fd62f
I guess this makes it even more important to use an API token to not run into request limits.