Skip to content

Commit

Permalink
Also cache alternate comment path
Browse files Browse the repository at this point in the history
  • Loading branch information
dflook committed Feb 11, 2024
1 parent 5544c09 commit d71de61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions image/src/github_actions/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, host: str, token: Optional[str], cache_path: Optional[str] =
if cache_path is not None:
urls_expire_after = {
re.compile(r'/repos/.*/.*/issues/\d+/comments'): 60 * 60 * 24 * 3,
re.compile(r'/repositories/.*/issues/.*/comments'): 60 * 60 * 24 * 3,
'*': EXPIRE_IMMEDIATELY
}

Expand Down Expand Up @@ -74,6 +75,7 @@ def patch(self, path: str, **kwargs: Any) -> Response:

def paged_get(self, url: GitHubUrl, *args, **kwargs) -> Iterable[dict[str, Any]]:
while True:

response = self.api_request('GET', url, *args, **kwargs)
response.raise_for_status()

Expand All @@ -83,6 +85,9 @@ def paged_get(self, url: GitHubUrl, *args, **kwargs) -> Iterable[dict[str, Any]]
yield from response.json()

if 'next' in response.links:
if 'params' in kwargs:
# Relevant params are already in the link URL
del kwargs['params']
url = response.links['next']['url']
else:
return
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
requests
requests-cache
pytest
python-hcl2
canonicaljson
Expand Down

0 comments on commit d71de61

Please sign in to comment.