Skip to content

Add person_metrics_export.py for external metric consumers - #515

Draft
bkraeling wants to merge 2 commits into
mainfrom
add-person-metrics-export
Draft

Add person_metrics_export.py for external metric consumers#515
bkraeling wants to merge 2 commits into
mainfrom
add-person-metrics-export

Conversation

@bkraeling

Copy link
Copy Markdown
Contributor

Issue

Surfacing a person's /team/<slug> card metrics (and their σ values) in an external dashboard meant scraping the HTML page — brittle, and it re-ran the expensive whole-team fetch on every view.

Solution

Adds person_metrics_export.py, a small read-only CLI that exports one person's card metrics + σ as JSON for arbitrary day windows. It calls _build_person_context, so the output matches the web page exactly — same values, same trimmed-baseline σ, same +/− orientation. No existing modules are changed and no new API surface is added.

python person_metrics_export.py --slug alice                       # JSON to stdout
python person_metrics_export.py --slug alice --windows 7,30,90 --out metrics.json

Output shape:

{
  "slug": "alice",
  "generated_at": 1756000000.0,
  "order": ["prs_merged", "..."],
  "labels": {"prs_merged": "PRs Merged"},
  "lower_is_better": ["avg_all_time_to_fix", "..."],
  "windows": {
    "7": {"prs_merged": {"value": 24, "sigma": "+0.3σ", "z": 0.3}}
  }
}

Notes:

  • --slug is required; --windows defaults to 7,30,90; output goes to stdout unless --out is given.
  • z is the σ label parsed to a float so consumers can threshold/colour without re-parsing (the label uses a Unicode minus).
  • Schedule-variance values are normalized to a compact signed form (+1d late / -1d early / 0d on time) for narrow displays.
  • The whole-team GitHub + Linear fetch is expensive, so this is intended to run on a schedule (e.g. daily), not per page view.

To Test

  • python person_metrics_export.py --slug <your-slug> prints JSON; values and σ match that person's /team/<slug> page for the default window
  • --windows 7,30,90 returns all three windows; --out <path> writes the file
  • Someone not on the engineering team returns metrics with no σ entries (relative metrics are engineering-only)
  • ruff check ., ruff format --check ., mypy ., vulture . --config pyproject.toml, and the unit tests pass

Verified locally: all four CI gates pass on the new file, and the existing 194 unit tests still pass.

🤖 Generated with Claude Code

Exports one person's card metrics and σ values as JSON for arbitrary day
windows, reusing _build_person_context so the output matches the /team/<slug>
page exactly (same values, same trimmed-baseline σ, same +/- orientation).

Motivation: surfacing these metrics in an external dashboard (a terminal
command center) previously meant scraping the HTML page. This gives a stable
JSON contract instead. The whole-team GitHub + Linear fetch is expensive, so
it is meant to run on a schedule rather than per view.

- writes to stdout by default, or --out <path>
- --slug is required; --windows defaults to 7,30,90
- schedule-variance values are normalized to a compact signed form
  (+1d late / -1d early / 0d on time) for narrow displays
- read-only: no new API surface, no changes to existing modules

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@redreceipt
redreceipt temporarily deployed to bug-board-add-person-me-qs1ze7 August 26, 2026 22:21 Inactive
Emit the engineering baseline (team mean and σ) alongside each metric's own σ,
plus the person's github_username and the configured orgs. Consumers can then
compare against the team average directly — e.g. "am I above the team's daily
rate today?" — instead of only seeing their own distance from it, and can query
the same GitHub surface without re-deriving this config.

The baseline is recovered from the σ tooltip that format_stdev_tooltip already
renders, so it stays in sync with the values the dashboard shows.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
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