A Python command line tool for gathering and summarising GitHub pull request statistics for users within an organisation. This tool helps track authored and reviewed pull requests over customisable date ranges.
- Authored pull requests: Count and list pull requests created by a specific author
- Reviewed pull requests: Count and list pull requests reviewed by a specific user
- Flexible Date Ranges: Filter by year, quarter, half-year, month, week, or a specific date
- Filtering Options: Limit to merged-only pull requests or exclude self-authored reviews
- Pagination Support: Configurable page sizes for efficient API usage
- Team Members: List members of a GitHub team within an organisation and gather per-member pull request counts
- Python 3.12 or higher
- uv package manager
- GitHub Personal Access Token with read permissions for the target organisation
-
Clone the repository:
git clone https://github.com/Jack-Waller/pull-request-statistics.git cd pull-request-statistics -
Install dependencies:
make install
Or using uv directly:
uv sync
Set the GITHUB_ACCESS_TOKEN environment variable with your GitHub Personal Access Token:
export GITHUB_ACCESS_TOKEN=your_github_token_hereThe token must have permissions to run search queries against the target organisation.
Using a .env file instead
If you prefer to store your token in a file, create a .env file in the project root:
GITHUB_ACCESS_TOKEN=your_github_token_hereThen use the --env-file flag when running uv:
uv run --env-file=.env src/main.py --user <login> --organisation <org>Run the tool using uv:
uv run src/main.py --user <login> --organisation <org>| Argument | Required | Description |
|---|---|---|
--user |
Yes (unless --team is used) |
GitHub login to analyse for authored and reviewed pull requests. Repeat to include multiple users |
--organisation |
Yes | GitHub organisation to search within |
--merged-only |
No | Limit authored results to merged pull requests |
--exclude-self-reviews |
No | Exclude self-authored pull requests when counting reviews |
--quarter |
No | Quarter to search (e.g., Q1, Q2, Q3, Q4) |
--half |
No | Half-year to search (e.g., H1, H2) |
--month |
No | Month name or number (e.g., March or 3) |
--week |
No | Use the most recent seven days ending today |
--year |
No | Year to search |
--date |
No | Specific date to search (YYYY-MM-DD) |
--page-size |
No | Page size for GitHub API pagination (default: 50) |
--counts-only |
No | Only fetch counts, skip fetching full pull request lists |
--team |
No | Team slug within the organisation to summarise. Counts-only output is enabled automatically and you can combine this with --user to include extra logins |
If no quarter, half, month, week, year, or date is provided, the tool defaults to the current quarter. When a team is provided or more than one user is supplied, counts-only mode is enabled automatically and the output is a per-member summary.
Get pull request statistics for the current quarter:
uv run src/main.py --user octocat --organisation githubGet merged pull requests only for Q1 2024:
uv run src/main.py --user octocat --organisation github --merged-only --quarter Q1 --year 2024Get review counts for a specific month:
uv run src/main.py --user octocat --organisation github --month March --year 2024Get stats for a specific date:
uv run src/main.py --user octocat --organisation github --date 2024-03-15List team members for a slug within an organisation:
uv run src/main.py --team mighty-llamas --organisation githubGet per-member counts (authored and reviewed) for a team over the most recent week:
uv run src/main.py --team mighty-llamas --organisation github --weekWhen using --team, the output includes per-member authored totals, reviewed totals, the percentage of the team's authored pull requests each member created, and—when --exclude-self-reviews is set—the percentage of other team members' pull requests each person reviewed.
Summarise multiple explicit users (counts-only is enabled automatically):
uv run src/main.py --user octocat --user hubot --organisation github --weekmake installRun linting checks using ruff:
make lintAuto-fix linting issues:
make fixFormat code:
make formatRun tests with linting:
make testRun tests with coverage report:
make coverageRemove build artifacts and caches:
make cleanpull-request-statistics/
├── src/
│ ├── main.py # Command line entry point
│ ├── require_env.py # Environment variable helper
│ └── github_client/ # GitHub GraphQL API client and domain logic
│ ├── client.py
│ ├── errors/
│ ├── pull_request_statistics/
│ │ ├── date_ranges/ # Date range utilities
│ │ ├── pull_request_statistics_service.py # Pull request query service
│ │ └── pull_request_summary.py # Pull request data model
│ └── team_members/
│ ├── team_member.py
│ └── team_members_service.py
├── tests/
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
├── Makefile # Build and development commands
├── pyproject.toml # Project configuration
└── README.md
See the repository for license information.