Added pagination for issues API

This commit is contained in:
Jules Lasne (jlasne - seluj78) 2019-12-10 15:35:35 +01:00
parent 2aaee0a7f6
commit 76783ca512

View File

@ -36,12 +36,20 @@ def get_repo_name(repo_path: str) -> str:
def get_reservation_list(repo_path: str) -> Mapping[str, str]:
"""Will get the repository name then request all the issues and put them in a dict
"""
# Gets the issues into a dict
issues = requests.get(
"https://api.github.com/repos/" + get_repo_name(repo_path) + "/issues"
).json()
# Creates the issue dict with the name and the login
reservations: dict = {
issue["title"].split()[-1].lower(): issue["user"]["login"] for issue in issues
}
issues: list = []
next = "https://api.github.com/repos/" + get_repo_name() + "/issues?state=open"
while next:
resp = requests.get(next)
issues += issues
next = resp.links.get("next", {}).get("url")
reservations = {}
for issue in issues:
# Maybe find a better way for not using python 3.8 ?
if re.search(r'\w*/\w*\.po', issue['title']):
yes = re.search(r'\w*/\w*\.po', issue['title'])
reservations[yes.group()] = issue['user']['login']
return reservations