Spec 022 — Overview success-rate widget (closes phase 4)#67
Merged
Conversation
Last spec of phase 4. Replace the mocked Deployments (24h) KpiCard on
/overview with a real query against workflow_runs. Locked decisions:
secondary line shows {rate}% success (B), sparkline stays daily
completed-run counts (A) for cross-card consistency, 95/80/0 status
thresholds with a muted floor for empty windows, and the 24h window
keys on run_completed_at so long-running jobs land in the bucket they
finished in.
Replace the mocked Deployments (24h) KpiCard on /overview with a real
aggregate against the workflow_runs table from spec 020. Last spec of
phase 4.
- GetOverviewDashboardQuery::deploymentsKpi() returns:
- successful_24h: count of completed-success runs in the last 24h
- success_rate_24h: integer percent (or null when no completed runs)
- change_percent: vs prior 24h, capped at [-100, +999]
- sparkline: 12-day daily count of completed runs
- status: muted (empty) | success (>=95) | warning (>=80) | danger
- Window keys on run_completed_at so long-running jobs land honestly.
- MOCK_KPIS['deployments'] removed; class docblock moves deployments
from "still mock" to "real today."
- TS DashboardPayload.deployments adds success_rate_24h: number | null.
- Overview.vue secondary prop renders "{rate}% success" or
"—% success" when null — keeps the card visually balanced on quiet
windows instead of pretending to know quality on no data.
Tests: 14 new tests covering zero state, 24h window scoping,
change-percent vs prior 24h, +999 cap, -100 floor, threshold seams at
95% and 80% (matters because round() makes 18/19 = 94.7 → 95), warning
and danger bands, sparkline daily counts, and sparkline excluding
in-progress runs. Existing "mock kpis stay phase-0" test trimmed to
drop the deployments assertion (graduated to real).
Self-review pass via superpowers:code-reviewer; addressed both findings
(boundary tests + cap-floor test added; index-deferral checkpoint
documented in spec work log rather than silently dropped).
run_completed_at index intentionally NOT added — phase-1 row counts
make the planner scan acceptable; revisit at ~5–10k workflow runs.
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.
Closes #66
Spec: specs/phase-4-deployments-cicd/022-overview-success-rate-widget.md
Last spec of phase 4 — Deployments & CI/CD now ships end-to-end: data layer (020), cross-repo timeline UI with realtime (021), and now the Overview KPI.
Summary
GetOverviewDashboardQuery::deploymentsKpi()aggregatesworkflow_runsover the last 24h (vs prior 24h) with three small helpers (completedRunCount,successfulRunCount,workflowRunSparkline) keeping the main method readable.successful_24h(primary),success_rate_24h(integer percent, null when empty window),change_percent(capped[-100, +999]), 12-day completed-runsparkline, and a 4-statestatus(muted/success/warning/danger).run_completed_at(notrun_started_at) so long-running jobs land in the bucket they finished in.MOCK_KPIS['deployments']removed; class docblock graduates the slice from "still mock" to "real today."Overview.vuesecondary prop now renders"{rate}% success"(or"—% success"when null) instead of static "Successful". TypeScriptDashboardPayload.deploymentsextended withsuccess_rate_24h: number | null.Test plan
vendor/bin/pint --testpasses.php artisan test— 14 net new passing tests (zero state, 24h window, change-percent + caps, threshold boundaries at 95%/80%, danger band, sparkline daily counts + in-progress exclusion). Full suite 282 passed (was 269). The 41 failures are env-only POST CSRF (419) — pre-existing baseline; CI passes them.npm run buildclean."24"+"92% success"+ green status on an active account; trigger a failing GH Action and confirm the rate moves; verify a quiet account renders"0"+"—% success"+ muted dot.Self-review notes
Self-review pass via
superpowers:code-reviewer; addressed both findings:round()makes 18/19 = 94.7 → 95) plus a-100cap-floor test (1 → 0 case).(status, conclusion, run_completed_at)would be optimal then.Phase 4 status
Phase complete. Roadmap pointers for what's next:
Plus carryover phase-3 polish: the activity heatmap on Overview is still mock — could be its own small
fix/PR when it earns priority.