A Python script to track and visualize GitHub pull request (PR) review activity in your repository. It collects data for the last week and generates plots to monitor review count, review time, messages, and inline code comments per engineer.
⸻
Features • Fetches PRs updated in the last week using GitHub API. • Tracks per-engineer metrics: • Total PR reviews (approvals / request changes / comment reviews) • Inline code review comments • Average time to first review • Number of review messages • Generates four plots:
- Weekly PR reviews per engineer (weekly_reviews.png)
- Average time to first review (avg_review_time.png)
- Messages left during review (review_messages.png)
- Combined reviews and inline comments (weekly_review_activity.png)
⸻
• Python 3.8+ • GitHub Personal Access Token with repo scope • Python packages:
pip install requests pandas matplotlib
⸻
- Clone the repository:
git clone https://github.com/your-org/weekly-pr-review-metrics.git
cd weekly-pr-review-metrics
2. Set your GitHub token as an environment variable:
export GITHUB_TOKEN=your_personal_access_token
3. Update configuration in the script if needed:
OWNER = "your-org-or-user" REPO = "your-repo" DAYS_BACK = 7 # number of days to include
⸻
Run the script:
python weekly_pr_review_metrics.py
• The script will fetch PRs updated in the last DAYS_BACK days.
• Generate metrics and save plots as PNG files in the current directory.
• Prints a leaderboard in the console showing each reviewer’s activity.
⸻
- weekly_reviews.png – Number of PR reviews per engineer
- avg_review_time.png – Average time to first review (hours)
- review_messages.png – Review messages per engineer
- weekly_review_activity.png – Combined grouped bar chart of reviews vs inline comments
⸻
• Inline comments (/pulls/{pr}/comments) are included in the combined activity. • Only PRs updated within the last DAYS_BACK days are included. • Names on the X-axis are rotated vertically for readability.