Skip to content

feat: Add initial python script #23

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

Conversation

rbarker-dev
Copy link
Contributor

Details:

Add initial v2query.py script which generates a json file containing all the project items for a given team

NEEDS CLEANUP and to be turned into a class

Related Issue(s):

closes #2

**Details**:

Add initial v2query.py script which generates a json file containing all
the project items for a given team

NEEDS CLEANUP and to be turned into a class

**Related Issue(s)**:

closes #2

Signed-off-by: Roger Barker <roger.barker@swirldslabs.com>
@rbarker-dev rbarker-dev added the feature New Feature label May 1, 2025
@rbarker-dev rbarker-dev requested a review from Copilot May 1, 2025 00:09
@rbarker-dev rbarker-dev self-assigned this May 1, 2025
@rbarker-dev rbarker-dev requested review from dpswirld and Copilot and removed request for Copilot and dpswirld May 1, 2025 00:09
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds an initial Python script (v2query.py) that generates a JSON file containing project items for a specified team by querying GitHub organizations, filtering projects by team name, fetching items via a CLI fallback, and consolidating them into a single file.

  • Implements GitHub API calls to retrieve organizations and projects.
  • Uses a command line tool to fetch project items and consolidates the results into a JSON file.
  • Cleans up temporary files after processing.

# so we use a subprocess call or GitHub REST if available.
# We'll fallback to CLI for now.
out_path = TEMP_DIR / f"{org}-{number}.items.json"
os.system( f'gh project item-list --owner "{org}" {number} --format json > "{out_path}"')
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using subprocess.run instead of os.system for improved error handling and to reduce potential command injection risks.

Suggested change
os.system( f'gh project item-list --owner "{org}" {number} --format json > "{out_path}"')
with open(out_path, "w") as out_file:
subprocess.run(
["gh", "project", "item-list", "--owner", org, str(number), "--format", "json"],
stdout=out_file,
check=True
)

Copilot uses AI. Check for mistakes.

"https://api.github.com/graphql",
json={"query": query, "variables": {"login": org}},
headers=headers
)
Copy link
Preview

Copilot AI May 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider checking the HTTP response status code before processing the JSON to ensure the API call succeeded.

Suggested change
)
)
if response.status_code != 200:
print(f"[red]Failed to fetch projects for org: {org}. HTTP {response.status_code}: {response.text}[/red]")
continue

Copilot uses AI. Check for mistakes.

@github-actions github-actions bot added the feat label May 1, 2025
@rbarker-dev rbarker-dev merged commit c7fe63b into main May 1, 2025
2 checks passed
@rbarker-dev rbarker-dev deleted the 2-feat-create-a-script-to-query-all-issues-from-github-given-a-user-or-team branch May 1, 2025 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat feature New Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: create a script to query all issues from GitHub given a user or team
2 participants