kopia lustrzana https://github.com/Langenfeld/py-gitea
feature: ability to only get first n pages to increase performance with paginated requests
rodzic
5aaa641bde
commit
df80317432
|
@ -426,11 +426,12 @@ class Repository(ApiObject):
|
|||
"""Get all Issues of this Repository (open and closed)"""
|
||||
return self.get_issues_state(Issue.OPENED) + self.get_issues_state(Issue.CLOSED)
|
||||
|
||||
def get_commits(self) -> List["Commit"]:
|
||||
def get_commits(self, page_limit: int = 0) -> List["Commit"]:
|
||||
"""Get all the Commits of this Repository."""
|
||||
try:
|
||||
results = self.gitea.requests_get_paginated(
|
||||
Repository.REPO_COMMITS % (self.owner.username, self.name)
|
||||
Repository.REPO_COMMITS % (self.owner.username, self.name),
|
||||
page_limit= page_limit
|
||||
)
|
||||
except ConflictException as err:
|
||||
logging.warning(err)
|
||||
|
|
|
@ -90,7 +90,12 @@ class Gitea:
|
|||
return self.parse_result(request)
|
||||
|
||||
def requests_get_paginated(
|
||||
self, endpoint: str, params=frozendict(), sudo=None, page_key: str = "page"
|
||||
self,
|
||||
endpoint: str,
|
||||
params=frozendict(),
|
||||
sudo=None,
|
||||
page_key: str = "page",
|
||||
page_limit: int = 0,
|
||||
):
|
||||
page = 1
|
||||
combined_params = {}
|
||||
|
@ -103,6 +108,8 @@ class Gitea:
|
|||
return aggregated_result
|
||||
aggregated_result.extend(result)
|
||||
page += 1
|
||||
if page_limit and page > page_limit:
|
||||
return aggregated_result
|
||||
|
||||
def requests_put(self, endpoint: str, data: dict = None):
|
||||
if not data:
|
||||
|
|
Ładowanie…
Reference in New Issue