Skip to content

Add first_review_to_last_approval_mean_time metric#1

Open
TheOrangePuff wants to merge 15 commits intomasterfrom
feature/first-review-to-last-approval
Open

Add first_review_to_last_approval_mean_time metric#1
TheOrangePuff wants to merge 15 commits intomasterfrom
feature/first-review-to-last-approval

Conversation

@TheOrangePuff
Copy link
Copy Markdown
Member

Description of the proposed changes

  • Average duration between the first non-author substantive review (APPROVED or CHANGES_REQUESTED) and the last non-author APPROVED review on a change.
  • Self-reviews and changes never approved are excluded.
  • New JSON decoder, helper, and metric in Backend/Queries.hs.
  • Backend test in Backend/Test.hs covering the happy path and the no-approval exclusion.

Screenshots (if applicable)

Other solutions considered (if any)

Notes to PR author

⚠️ Please make sure the changes adhere to the guidelines mentioned in our contribution guide.

Notes to reviewers

ℹ️ When you've finished leaving feedback, please add a final comment to the PR tagging the author, letting them know that you have finished leaving feedback

- Average duration between the first non-author substantive review
  (APPROVED or CHANGES_REQUESTED) and the last non-author APPROVED
  review on a change.
- Self-reviews and changes never approved are excluded.
- New JSON decoder, helper, and metric in Backend/Queries.hs.
- Backend test in Backend/Test.hs covering the happy path and the
  no-approval exclusion.
Adds a step to tag and push the locally-built monocle image to
ghcr.io/aligent/monocle:dev (and a SHA tag) so the image can be
pulled and run on developer machines without rebuilding from source.
Relude hides Foldable.minimum/maximum as partial; the project's
Prelude follows that. Switch to Data.List.minimum/maximum guarded by
explicit non-empty pattern match.
Server.hs:923 has a hand-coded case mapping metric names to
implementations for the metric/get endpoint. allMetrics in Queries.hs
only feeds metric/list and metric/info, so adding a metric there
isn't enough to make it executable.
The previous trend bucketed by change-creation date, which causes
right-censoring at the trailing edge: recent buckets only contain
changes that completed review fast enough to be done already. As
late-approving changes land they push the bucket up retroactively,
so 'recent months are improving' is a measurement artifact, not a
real trend.

Bucket by the change's last-approval timestamp instead. Once a
month closes on the calendar, no future approvals can land in
it, so the value is final.

Also add first_review_to_last_approval_median_time. Median is more
robust to slow-tail outliers than mean, which is appropriate for
right-skewed review-duration data.
Removes workflows that aren't load-bearing for the build-and-pull
flow we use locally:

- docker-ubi.yaml — UBI variant of the container; not used.
- k8s.yaml — k8s deployment validation; we run compose, not k8s.
- nix.yaml — api-tests via nix; was failing on cosmetic formatter.
- web.yaml — frontend tests; we don't touch the frontend.
- nix-build.yaml, publish-master.yaml, publish-tag.yaml — guarded
  to change-metrics org or tag-triggered; never fire on this fork.

Adds a concurrency block to docker.yaml so a newer push cancels
older in-progress runs on the same ref.
Same as the regular mean but drops events whose reviewer or change
author looks like a bot. Heuristic: muid ends in [bot] (catches
GitHub's official bot suffix) or matches a small allowlist for
service accounts that don't carry the suffix (dependabot, vercel,
github-actions, aikido-*, copilot-pull-request-reviewer,
github-advanced-security, renovate-bot, aligent-ai-code-reviewer).

The data and trend helpers gain an includeMuid predicate so future
'exclude X' variants are cheap to add.
A 'single-approve' PR is one that received at least one APPROVED
review and zero CHANGES_REQUESTED reviews — the team approved on
first read without iteration.

Two metrics:
- single_approve_percentage: 0..100, all reviewers/authors counted.
- single_approve_percentage_excluding_bots: same but bot accounts
  are dropped from numerator and denominator (using the existing
  isBotMuid heuristic).

Self-reviews are dropped. PRs that never received an approving
review are excluded from the denominator. The trend buckets by the
change's last-approval date, matching the duration metrics.
- Single-page dashboard at :3001 calling the existing /api/2/metric/get,
  showing summary + line chart + bucket-mean table for the two
  excluding-bots variants of first-review-to-last-approval mean time
  and single-approve PR percentage.
- Configurable from-date (date picker + 7d/30d/3mo/6mo/1y presets) and
  trend interval. API URL and workspace persist to localStorage.
- nginx:alpine service with no-store cache, bind-mounted from
  alt-frontend/ for live edits.
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.

1 participant