removed page iteration from listing issues as "-1" is a valid parameter for the api listing all issues

pull/3/head
Langenfeld 2019-12-10 18:21:20 +01:00
rodzic 257abeb13b
commit 11bf6f8dc9
1 zmienionych plików z 9 dodań i 14 usunięć

Wyświetl plik

@ -185,21 +185,16 @@ class Repository(GiteaApiObject):
def get_issues_state(self, state) -> List[GiteaApiObject]: def get_issues_state(self, state) -> List[GiteaApiObject]:
"""Get issues of state Issue.open or Issue.closed of a repository.""" """Get issues of state Issue.open or Issue.closed of a repository."""
assert state in [Issue.OPENED, Issue.CLOSED] assert state in [Issue.OPENED, Issue.CLOSED]
index = 1
issues = [] issues = []
while True: # "page": -1 is returning _all_ issues instead of pages. Hopefully this is intended behaviour.
# q=&type=all&sort=&state=open&milestone=0&assignee=0 data = {"page": -1, "state": state}
results = self.gitea.requests_get(Repository.REPO_ISSUES % (self.owner.username, self.name), results = self.gitea.requests_get(Repository.REPO_ISSUES % (self.owner.username, self.name), params=data)
params={"page": index, "state": state}) for result in results:
if len(results) <= 0: issue = Issue.parse_request(self.gitea, result)
break # adding data not contained in the issue answer
index += 1 setattr(issue, "repo", self.name)
for result in results: setattr(issue, "owner", self.owner)
issue = Issue.parse_request(self.gitea, result) issues.append(issue)
# again a hack because this infomation gets lost after the api call
setattr(issue, "repo", self.name)
setattr(issue, "owner", self.owner)
issues.append(issue)
return issues return issues
def get_user_time(self, username) -> float: def get_user_time(self, username) -> float: