Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MisRob
Copy link
Member

@MisRob MisRob commented Feb 7, 2025

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.

Screenshot from 2025-02-07 16-27-28

@MisRob MisRob requested review from rtibbles and ozer550 February 7, 2025 15:28
Copy link
Member

@ozer550 ozer550 left a 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:
Copy link
Member

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:
Copy link
Member

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.

@MisRob
Copy link
Member Author

MisRob commented Feb 10, 2025

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.

@rtibbles rtibbles self-assigned this Feb 11, 2025
@MisRob
Copy link
Member Author

MisRob commented Feb 12, 2025

Done @ozer550, would you re-review please?

@MisRob MisRob requested a review from ozer550 February 12, 2025 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants