-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save the script that lists all issues assigned to community #17
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of ideas or thoughts I had in my mind while reviewing. Some things to think about if we would increase the functionality of the script. Else this looks good.
"""Fetch all team members for the organization.""" | ||
team_members = set() | ||
url = f"{BASE_URL}/orgs/{org}/members" | ||
while url: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that we are doing manual pagination here. I was curious to know if it would be helpful to use external libraries to handle this kind of stuff? Searching a bit I see quite a lot of them https://github.com/PyGithub/PyGithub and some third party suggested once by Github. I know this might be an overkill for this but, just wanted to think about this if there's any further scope of development of the script.
"""Fetch all issues for a specific repository.""" | ||
issues = [] | ||
url = f"{BASE_URL}/repos/{org}/{repo}/issues?state=open" | ||
while url: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we could also extract the fetch functionality something like this?
def fetch_paginated_results(url):
results = []
while url:
response = requests.get(url, headers=HEADERS)
response.raise_for_status()
results.extend(response.json())
url = response.links.get("next", {}).get("url")
return results
This way we could use this in any other future functions as well.
Thank you @ozer550, yes that's good ideas :) I think at this point I'd prefer the second alternative you suggest - to extract the pagination logic to a utility function. The library may be handy too, even though perhaps we can wait for a bit at first and introduce it only if we need it in more scripts - for now it's just here and it's just me using it from time to time. |
Done @ozer550, would you re-review please? |
Summary
This is a script I use locally to print all issues assigned to community contributors. Saving here so it's in a shared location.