Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improved get top contrib script #1710

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down
27 changes: 14 additions & 13 deletions content-repo/gen_top_contrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,25 +131,26 @@ def github_pagination_prs(url: str, params: dict, res) -> list:
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:
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

Expand Down
Loading