Skip to content

Add PR activity report generator#1609

Merged
aliasaria merged 3 commits intomainfrom
add/pr-stats-report-generator
Mar 23, 2026
Merged

Add PR activity report generator#1609
aliasaria merged 3 commits intomainfrom
add/pr-stats-report-generator

Conversation

@aliasaria
Copy link
Copy Markdown
Member

Summary

  • Adds scripts/pr-stats/generate.py — fetches PR data via gh CLI and generates an interactive HTML dashboard
  • Stacked bar chart, line chart, doughnut chart, and leaderboard table
  • Contributor filter panel with checkboxes to show/hide individual team members — all charts and stats update live
  • Usage: python scripts/pr-stats/generate.py --open
  • Generated report.html is gitignored

Test plan

  • Run python scripts/pr-stats/generate.py --open and verify the report opens in browser
  • Toggle contributor checkboxes and confirm all charts/stats/table update correctly
  • Test Select All / Deselect All buttons
  • Verify scripts/pr-stats/report.html does not appear in git status

Fetches PR data via gh CLI and generates an interactive HTML dashboard
with stacked bar, line, and doughnut charts. Includes contributor
filter checkboxes to show/hide individual team members.
@paragon-review
Copy link
Copy Markdown

Paragon Summary

This pull request review identified 2 issues across 2 categories in 2 files. The review analyzed code changes, potential bugs, security vulnerabilities, performance issues, and code quality concerns using automated analysis tools.

This PR adds a Python script that generates an interactive HTML dashboard visualizing PR activity data via stacked bar charts, line charts, doughnut charts, and a contributor leaderboard with live filtering by team member. The generated report file is excluded from git to keep the repository clean.

Key changes:

  • Added scripts/pr-stats/generate.py — fetches PR data via gh CLI and generates interactive HTML dashboard
  • Dashboard includes stacked bar chart, line chart, doughnut chart, and leaderboard table
  • Contributor filter panel with checkboxes for live filtering of all charts/stats
  • Added .gitignore to exclude generated report.html from version control

Confidence score: 3/5

  • This PR has moderate risk due to 1 high-priority issue that should be addressed
  • Score reflects significant bugs, performance issues, or architectural concerns
  • Review high-priority findings carefully before merging

2 files reviewed, 2 comments

Severity breakdown: High: 1, Low: 1


Tip: @paragon-run <instructions> to chat with our agent or push fixes!

Dashboard

weekly: dict[str, dict[str, int]] = defaultdict(lambda: defaultdict(int))
authors: set[str] = set()

for pr in prs:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Security: Null author crash when PR author deleted their account

Null author crash when PR author deleted their account. Any repo with historical PRs from deleted users will crash entirely. Guard with safe navigation before accessing login.

View Details

Location: scripts/pr-stats/generate.py (lines 328)

Analysis

Null author crash when PR author deleted their account

What fails GitHub returns 'author': null for PRs from deleted accounts; the code unconditionally accesses pr['author']['login'] causing a TypeError crash.
Result TypeError: 'NoneType' object is not subscriptable — no report is generated
Expected Script should handle null authors gracefully (e.g. attribute them to '[deleted]') and continue generating the report
Impact Any repository with even one historical PR from a deleted account causes the entire report generation to fail with no output.
How to reproduce
1. Have a repo with at least one PR from a deleted GitHub account
2. Run: python scripts/pr-stats/generate.py
3. Observe crash in build_report()
Patch Details
-        author = pr["author"]["login"]
+        author = (pr.get("author") or {}).get("login") or "[deleted]"
AI Fix Prompt
Fix this issue: Null author crash when PR author deleted their account. Any repo with historical PRs from deleted users will crash entirely. Guard with safe navigation before accessing login.

Location: scripts/pr-stats/generate.py (lines 328)
Problem: GitHub returns 'author': null for PRs from deleted accounts; the code unconditionally accesses pr['author']['login'] causing a TypeError crash.
Current behavior: TypeError: 'NoneType' object is not subscriptable — no report is generated
Expected: Script should handle null authors gracefully (e.g. attribute them to '[deleted]') and continue generating the report
Steps to reproduce: 1. Have a repo with at least one PR from a deleted GitHub account
2. Run: python scripts/pr-stats/generate.py
3. Observe crash in build_report()

Provide a code fix.


Tip: Reply with @paragon-run to automatically fix this issue

Dynamically fetch the repo name via gh CLI instead of hardcoding it.
@aliasaria aliasaria merged commit f6546b4 into main Mar 23, 2026
4 of 5 checks 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