You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "kou (via GitHub)" <gi...@apache.org> on 2023/07/13 05:25:26 UTC
[GitHub] [arrow] kou commented on a diff in pull request #36637: GH-36634: [Dev] Ensure merge script goes over all pages when requesting info from GitHub
kou commented on code in PR #36637:
URL: https://github.com/apache/arrow/pull/36637#discussion_r1261999247
##########
dev/merge_arrow_pr.py:
##########
@@ -78,7 +78,26 @@ def get_json(url, headers=None):
response = requests.get(url, headers=headers)
if response.status_code != 200:
raise ValueError(response.json())
- return response.json()
+ # GitHub returns a link header with the next, previous, last
+ # page if there is pagination on the response. See:
+ # https://docs.github.com/en/rest/guides/using-pagination-in-the-rest-api#using-link-headers
+ next_responses = None
+ if "link" in response.headers:
+ links = response.headers['link'].split(', ')
+ next_url = None
+ for link in links:
+ if 'rel="next"' in link:
+ # Format: '<url>; rel="next"'
+ next_url = link.split(";")[0][1:-1]
+ if next_url:
+ next_responses = get_json(next_url, headers)
Review Comment:
Can we simplify this?
```suggestion
for link in links:
if 'rel="next"' in link:
# Format: '<url>; rel="next"'
next_url = link.split(";")[0][1:-1]
next_responses = get_json(next_url, headers)
```
##########
dev/merge_arrow_pr.py:
##########
@@ -78,7 +78,26 @@ def get_json(url, headers=None):
response = requests.get(url, headers=headers)
if response.status_code != 200:
raise ValueError(response.json())
- return response.json()
+ # GitHub returns a link header with the next, previous, last
+ # page if there is pagination on the response. See:
+ # https://docs.github.com/en/rest/guides/using-pagination-in-the-rest-api#using-link-headers
+ next_responses = None
+ if "link" in response.headers:
+ links = response.headers['link'].split(', ')
+ next_url = None
+ for link in links:
+ if 'rel="next"' in link:
+ # Format: '<url>; rel="next"'
+ next_url = link.split(";")[0][1:-1]
+ if next_url:
+ next_responses = get_json(next_url, headers)
+ ret_val = response.json()
Review Comment:
Can we use better name something like `responses`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org