Add person_metrics_export.py for external metric consumers - #515
Draft
bkraeling wants to merge 2 commits into
Draft
Add person_metrics_export.py for external metric consumers#515bkraeling wants to merge 2 commits into
bkraeling wants to merge 2 commits into
Conversation
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]>
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.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:
--slugis required;--windowsdefaults to7,30,90; output goes to stdout unless--outis given.zis the σ label parsed to a float so consumers can threshold/colour without re-parsing (the label uses a Unicode minus).+1dlate /-1dearly /0don time) for narrow displays.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,90returns all three windows;--out <path>writes the fileruff check .,ruff format --check .,mypy .,vulture . --config pyproject.toml, and the unit tests passVerified locally: all four CI gates pass on the new file, and the existing 194 unit tests still pass.
🤖 Generated with Claude Code