Skip to content

Commit d71de61

Browse files
committed
Also cache alternate comment path
1 parent 5544c09 commit d71de61

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

image/src/github_actions/api.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def __init__(self, host: str, token: Optional[str], cache_path: Optional[str] =
2323
if cache_path is not None:
2424
urls_expire_after = {
2525
re.compile(r'/repos/.*/.*/issues/\d+/comments'): 60 * 60 * 24 * 3,
26+
re.compile(r'/repositories/.*/issues/.*/comments'): 60 * 60 * 24 * 3,
2627
'*': EXPIRE_IMMEDIATELY
2728
}
2829

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

7576
def paged_get(self, url: GitHubUrl, *args, **kwargs) -> Iterable[dict[str, Any]]:
7677
while True:
78+
7779
response = self.api_request('GET', url, *args, **kwargs)
7880
response.raise_for_status()
7981

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

8587
if 'next' in response.links:
88+
if 'params' in kwargs:
89+
# Relevant params are already in the link URL
90+
del kwargs['params']
8691
url = response.links['next']['url']
8792
else:
8893
return

tests/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
requests
2+
requests-cache
23
pytest
34
python-hcl2
45
canonicaljson

0 commit comments

Comments
 (0)