Skip to content

Commit

Permalink
Increase items limit for autoupdater
Browse files Browse the repository at this point in the history
  • Loading branch information
tituspijean authored and Salamandar committed Sep 14, 2024
1 parent aba47e9 commit 588d4a2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions autoupdate_app_sources/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from urllib.parse import urljoin
import requests

ITEMS_LIMIT=100

class RefType(Enum):
tags = 1
commits = 2
releases = 3


class GithubAPI:
def __init__(self, upstream: str, auth: Optional[tuple[str, str]] = None):
self.upstream = upstream.strip("/")
Expand All @@ -32,15 +32,15 @@ def internal_api(self, uri: str) -> Any:

def tags(self) -> list[dict[str, str]]:
"""Get a list of tags for project."""
return self.internal_api(f"repos/{self.upstream_repo}/tags")
return self.internal_api(f"repos/{self.upstream_repo}/tags?per_page={ITEMS_LIMIT}"

def commits(self) -> list[dict[str, Any]]:
"""Get a list of commits for project."""
return self.internal_api(f"repos/{self.upstream_repo}/commits")

def releases(self) -> list[dict[str, Any]]:
"""Get a list of releases for project."""
return self.internal_api(f"repos/{self.upstream_repo}/releases?per_page=100")
return self.internal_api(f"repos/{self.upstream_repo}/releases?per_page={ITEMS_LIMIT}"

def url_for_ref(self, ref: str, ref_type: RefType) -> str:
"""Get a URL for a ref."""
Expand Down Expand Up @@ -102,7 +102,7 @@ def internal_api(self, uri: str) -> Any:

def tags(self) -> list[dict[str, str]]:
"""Get a list of tags for project."""
return self.internal_api(f"projects/{self.project_id}/repository/tags")
return self.internal_api(f"projects/{self.project_id}/repository/tags?per_page={ITEMS_LIMIT}"

def commits(self) -> list[dict[str, Any]]:
"""Get a list of commits for project."""
Expand All @@ -118,7 +118,7 @@ def commits(self) -> list[dict[str, Any]]:
def releases(self) -> list[dict[str, Any]]:
"""Get a list of releases for project."""
releases = self.internal_api(f"projects/{self.project_id}/releases")
releases = self.internal_api(f"projects/{self.project_id}/releases?per_page={ITEMS_LIMIT}"
retval = []
for release in releases:
r = {
Expand Down Expand Up @@ -186,15 +186,15 @@ def internal_api(self, uri: str):
def tags(self) -> list[dict[str, Any]]:
"""Get a list of tags for project."""
return self.internal_api(f"repos/{self.project_path}/tags")
return self.internal_api(f"repos/{self.project_path}/tags?limit={ITEMS_LIMIT}"
def commits(self) -> list[dict[str, Any]]:
"""Get a list of commits for project."""
return self.internal_api(f"repos/{self.project_path}/commits")
def releases(self) -> list[dict[str, Any]]:
"""Get a list of releases for project."""
return self.internal_api(f"repos/{self.project_path}/releases")
return self.internal_api(f"repos/{self.project_path}/releases?limit={ITEMS_LIMIT}"
def url_for_ref(self, ref: str, _: RefType) -> str:
"""Get a URL for a ref."""
Expand Down

0 comments on commit 588d4a2

Please sign in to comment.