pr-stats command#

The PR activity report command is available either as a script:

pr-stats xadupre my-own-accelerator --prefix pr_activity

or through the package entrypoint:

python -m moa pr-stats xadupre my-own-accelerator

Synopsis:

    usage: python -m moa sphinx-build [-h] [--token TOKEN] [--api-url API_URL]
                                      [--output-dir OUTPUT_DIR] [--prefix PREFIX]
                                      [--since SINCE] [--cache-file CACHE_FILE]
                                      owner repo
    
    Builds a report of completed pull requests with author, manual comments,
    Copilot commands, dates, and output files.
    
    positional arguments:
      owner                 GitHub repository owner
      repo                  GitHub repository name
    
    options:
      -h, --help            show this help message and exit
      --token TOKEN         GitHub personal access token
      --api-url API_URL     GitHub API base URL
      --output-dir OUTPUT_DIR
                            Directory where output files are written (default:
                            dump_pr_stats).
      --prefix PREFIX       Filename prefix for generated files (default:
                            pr_activity_<repo>).
      --since SINCE         Only include PRs created on/after this datetime (YYYY-
                            MM-DD, ISO 8601 datetime, or relative values like '-1
                            day' or '-3d'). Default: 6 months ago.
      --cache-file CACHE_FILE
                            Optional cache file path for PR statistics. Defaults
                            to <output-dir>/<prefix>_cache.json.

The command scans completed pull requests (open PRs are skipped) and produces:

  • <prefix>.csv

  • <prefix>.xlsx

  • graphs_<repo>/<prefix>_status.svg

  • graphs_<repo>/<prefix>_comments.svg

  • graphs_<repo>/<prefix>_prs_per_week.svg

  • graphs_<repo>/<prefix>_comments_per_pr.svg — distribution of PRs by number of comments

  • graphs_<repo>/<prefix>_comments_per_week.svg

  • graphs_<repo>/<prefix>_graphs.html — final HTML report embedding all generated graphs

  • graphs_<repo>/<prefix>_job_duration_<job>.svg (one per unique job name, successful runs only)

Each row includes pull request author, creation datetime, merge/close status, manual comment count, Copilot command count, and total workflow job duration for that PR (in seconds). The Excel workbook also includes per-week PR counts, per-PR comment totals, per-week comment totals, a comment-count distribution, average PR duration per author and week, and a Job durations sheet listing the duration of every successful workflow job across all scanned PRs. A line-graph SVG is produced for each unique job name, showing duration over time with a 10-run moving average.

Use --since to only include pull requests created on/after a given date (YYYY-MM-DD or ISO datetime), and --cache-file to control where the PR statistics cache is stored. By default, cache is written to <output-dir>/<prefix>_cache.json and cached PR rows are reused on subsequent runs instead of requesting their comment statistics again. Generated files are written to the dump_pr_stats directory by default, with SVG graphs stored in a repo-specific graphs_<repo> subdirectory. By default, generated file names use the pr_activity_<repo> prefix. Use -v or --verbose to print progress information to standard error while the command is running, including which token source/type is used.