Skip to content

Add Python script and GitHub Actions workflow for user statistics#1

Merged
rajbos merged 7 commits intomainfrom
copilot/add-python-script-and-workflow
Dec 21, 2025
Merged

Add Python script and GitHub Actions workflow for user statistics#1
rajbos merged 7 commits intomainfrom
copilot/add-python-script-and-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 20, 2025

Implements automated GitHub user activity tracking using GraphQL API to fetch pull requests, issues, and discussions for configurable time periods.

Core Implementation

  • fetch_user_stats.py: GraphQL-based fetcher with configurable lookback period and user

    • Fetches 100 most recent items per type (PRs, issues, discussions) with client-side date filtering
    • Outputs formatted statistics with emoji indicators and activity summaries
    • --output-file flag for file output; status messages routed to stderr for clean stdout
    • GitHub Actions step summary integration: Automatically detects GITHUB_STEP_SUMMARY environment variable and writes output to both console and step summary file for easy viewing in workflow run pages
  • .github/workflows/user-stats.yml: Automated execution via workflow_dispatch, scheduled weekly runs, and push triggers

    • Single API call optimization using --output-file
    • 30-day artifact retention for reports
    • Statistics automatically displayed in GitHub Actions step summary

Usage

# Default: user 'rajbos', 30-day lookback
python fetch_user_stats.py

# Custom parameters
python fetch_user_stats.py --username octocat --days 90 --output-file report.txt

Limitations

  • 100-item limit per query type due to GitHub GraphQL API constraints
  • Client-side date filtering; items beyond 100 most recent may be missed for active users
  • Consider shorter lookback periods for comprehensive coverage

Dependencies

  • Python 3.7+ (uses datetime.fromisoformat)
  • requests>=2.31.0
Original prompt

Got it! I’ll create a new repository called GitHub User Statistics and add the Python script and GitHub Actions workflow into it as requested. Here's the planned implementation:

  1. Python Script:

    • Will use GitHub's REST API or GraphQL API to fetch user activity data, including pull requests, issues, and discussions for your GitHub user (rajbos).
    • Script will support configuring the lookback period to specify the number of days to analyze.
  2. GitHub Actions Workflow:

    • Automates the execution of the Python script.
    • Validates its functionality and outputs the results directly as part of the GitHub Actions logs or uploads them as an artifact.
  3. Repository Setup:

    • A new repository named GitHub User Statistics will be created.
    • The Python script and workflow YAML file will be added to this repo.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits December 20, 2025 15:44
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Python script and GitHub Actions workflow for user statistics Add Python script and GitHub Actions workflow for user statistics Dec 20, 2025
Copilot AI requested a review from rajbos December 20, 2025 15:54
@rajbos
Copy link
Copy Markdown
Contributor

rajbos commented Dec 20, 2025

@copilot update the print commands with a new method. In the new method, detect the GitHub step summary environment variable and if so, use both print as well as a write line to the filename in the variable.

Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Dec 20, 2025

@copilot update the print commands with a new method. In the new method, detect the GitHub step summary environment variable and if so, use both print as well as a write line to the filename in the va...

Added _print_and_log() method that detects GITHUB_STEP_SUMMARY environment variable and writes to both stdout and the step summary file. All print statements in print_statistics() now use this method.

Commit: f2a4419

@rajbos rajbos marked this pull request as ready for review December 21, 2025 10:47
Comment thread .github/workflows/user-stats.yml Outdated
@rajbos rajbos merged commit e7c7d4b into main Dec 21, 2025
1 check passed
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.

2 participants