From 1d437415025b7072942bdab3f1703569740569c5 Mon Sep 17 00:00:00 2001 From: meichler Date: Wed, 5 Mar 2025 10:38:27 +0200 Subject: [PATCH 1/3] add print --- content-repo/gen_top_contrib.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content-repo/gen_top_contrib.py b/content-repo/gen_top_contrib.py index 28b27addc..63056f548 100755 --- a/content-repo/gen_top_contrib.py +++ b/content-repo/gen_top_contrib.py @@ -123,7 +123,7 @@ def get_external_prs(prs: list) -> List[Dict]: return external_prs -def github_pagination_prs(url: str, params: dict, res) -> list: +def github_pagination_prs(url: str, params: dict, res) -> list | None: """ Paginate through all the pages in Github according to search query Args: @@ -139,6 +139,7 @@ def github_pagination_prs(url: str, params: dict, res) -> list: last_page = links[-1] last_page_link = last_page[last_page.find("<") + 1:last_page.find(">")] try: + print(f"Fetching last_page_link {last_page_link}") last_pr_number = PAGE_NUMBER_REGEX.search(last_page_link)[0] except IndexError: print(f"Error: Couldn't find the last page number. \n Last page link - {last_page_link}") From 3900980498f468a16403020ec5a55027d0e38e71 Mon Sep 17 00:00:00 2001 From: meichler Date: Wed, 5 Mar 2025 16:06:59 +0200 Subject: [PATCH 2/3] fix none is not iterable --- content-repo/gen_top_contrib.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/content-repo/gen_top_contrib.py b/content-repo/gen_top_contrib.py index 63056f548..956401cce 100755 --- a/content-repo/gen_top_contrib.py +++ b/content-repo/gen_top_contrib.py @@ -123,7 +123,7 @@ def get_external_prs(prs: list) -> List[Dict]: return external_prs -def github_pagination_prs(url: str, params: dict, res) -> list | None: +def github_pagination_prs(url: str, params: dict, res) -> list: """ Paginate through all the pages in Github according to search query Args: @@ -131,26 +131,26 @@ def github_pagination_prs(url: str, params: dict, res) -> list | None: params (dict): params for the request res: the response from the http_request - Returns: prs (dict) + Returns: prs (list) """ prs = [] if link := res.headers.get('Link'): links = link.split(',') last_page = links[-1] last_page_link = last_page[last_page.find("<") + 1:last_page.find(">")] - try: - print(f"Fetching last_page_link {last_page_link}") - last_pr_number = PAGE_NUMBER_REGEX.search(last_page_link)[0] - except IndexError: - print(f"Error: Couldn't find the last page number. \n Last page link - {last_page_link}") - return - - while params['page'] < int(last_pr_number): - params['page'] = params['page'] + 1 - response = search_session.request('GET', url, params=params, headers=HEADERS, verify=VERIFY) - response.raise_for_status() - next_page_prs = response.json().get('items', []) - prs.extend(next_page_prs) + print(f"{last_page_link}: {last_page}") + + match = PAGE_NUMBER_REGEX.search(last_page_link) + if match: + last_pr_number = int(match.group(1)) + while params['page'] < last_pr_number: + params['page'] = params['page'] + 1 + response = search_session.request('GET', url, params=params, headers=HEADERS, verify=VERIFY) + response.raise_for_status() + next_page_prs = response.json().get('items', []) + prs.extend(next_page_prs) + else: + print(f"Warning: Couldn't find the last page number. Last page link - {last_page_link}") return prs From d2ed3d77b4dd5d4b33686ea673e9302036c33992 Mon Sep 17 00:00:00 2001 From: meichler Date: Wed, 5 Mar 2025 16:13:06 +0200 Subject: [PATCH 3/3] upgrade action cache --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4b4132975..7cd7d4631 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,14 +21,14 @@ jobs: with: node-version: "${{ steps.nvm.outputs.NVMRC }}" - name: Cache npm - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~/.npm key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-node- - name: Cache pip - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~/.cache/pip key: ${{ runner.os }}-pip-${{ hashFiles('**/Pipfile.lock') }}