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
Open
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
69 changes: 69 additions & 0 deletions scripts/get_community_assigned_issues.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Prints a list of links to all issues that are assigned
# to external contributors.
# This is not used by any workflows, and meant to be used locally
# whenever need arises. The script requires `GITHUB_TOKEN`
# environment variable with 'repo' and 'read:org' permissions.

import os
import requests

ORG = "learningequality"
REPOS = ["kolibri", "studio", "kolibri-design-system", "le-utils", ".github","ricecooker"]

TOKEN = os.getenv("GITHUB_TOKEN")
if not TOKEN:
raise EnvironmentError("Please set the GITHUB_TOKEN environment variable with 'repo' and 'read:org' permissions.")

BASE_URL = "https://api.github.com"
HEADERS = {
"Authorization": f"token {TOKEN}",
"Accept": "application/vnd.github+json"
}

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

def get_team_members(org):
"""Fetch all team members for the organization."""
results = fetch_paginated_results(f"{BASE_URL}/orgs/{org}/members")
team_members = [member["login"] for member in results]
return team_members

def get_issues_for_repo(org, repo):
"""Fetch all issues for a specific repository."""
return fetch_paginated_results(f"{BASE_URL}/repos/{org}/{repo}/issues?state=open")

def filter_issues(issues, team_members):
"""Filter issues assigned to external contributors"""
return [
issue for issue in issues
if issue.get("assignee") and issue["assignee"]["login"] not in team_members
]

def main():
team_members = get_team_members(ORG)
print(f"Found {len(team_members)} team members in {ORG}.")

all_filtered_issues = []
print(f"Processing {len(REPOS)} repositories in {ORG}...")

for repo in REPOS:
print(f"Processing repository: {repo}")
issues = get_issues_for_repo(ORG, repo)
filtered_issues = filter_issues(issues, team_members)
all_filtered_issues.extend(
issue["html_url"]
for issue in filtered_issues
)

for url in all_filtered_issues:
print(url)

if __name__ == "__main__":
main()