Skip to content

feat(stats): add a public review-volume/filtered-rate trend and 2 more hero sparklines - #4722

Merged
JSONbored merged 1 commit into
mainfrom
feat/public-review-volume-trend-4445followup
Jul 10, 2026
Merged

feat(stats): add a public review-volume/filtered-rate trend and 2 more hero sparklines#4722
JSONbored merged 1 commit into
mainfrom
feat/public-review-volume-trend-4445followup

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

  • Extends GET /v1/public/stats with reviewVolumeTrend — the last two homepage headline tiles ("PRs reviewed", "Filtered without merge") were the only ones left without a sparkline, since neither had a persisted weekly series before this.
  • Deliberately a per-week cohort, not an independent per-day event count like accuracyTrend's merged/closed split: a PR credits the week it was first published, and merged reflects its current disposition regardless of which week it actually merged. filteredPct only means anything evaluated against a fixed PR set, so a cohort is the only formulation that stays consistent with the lifetime totals.filteredPct figure it mirrors.
  • Wires both tiles to their own 8-week sparklines (--chart-3, --chart-4), completing all 5 hero tiles — "Maintainer time saved" is the one intentionally left without one, since it's reviewed × ~20min, a fixed multiple of the first tile, so its own trend would just be a rescaled copy of the same line.

Closes #4721.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves.

Validation

  • git diff --check
  • npm run actionlint — skipped, no .github/workflows/** changes.
  • npm run typecheck
  • npm run test:coverage (targeted, not the full unsharded suite — see Notes) locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed. Verified every changed line in src/api/routes.ts, src/openapi/schemas.ts, and the new src/services/public-review-volume-trend.ts is hit, via test/unit/public-review-volume-trend.test.ts (100% stmts/branch/funcs/lines on the new file), test/integration/public-stats-route.test.ts (extended), and test/integration/public-stats-route-error.test.ts (unchanged, already covers the shared Promise.all catch path).
  • npm run test:workers — skipped, no Worker-specific code touched beyond what typecheck/test:coverage already cover.
  • npm run build:mcp / npm run test:mcp-pack — skipped, no MCP package changes.
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries — see Notes for the full list.

If any required check was skipped, explain why:

  • test:workers and the MCP checks are unrelated to this diff's surface (a new service module + one route field + a UI model/component extension); typecheck + the targeted coverage above already validate the actual change.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth/cookie/CORS/GitHub App/Cloudflare/session changes include negative-path tests — N/A, none touched.
  • API/OpenAPI/MCP behavior is updated and tested where needed — new reviewVolumeTrend field, OpenAPI regenerated + ui:openapi:check clean.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks — both new sparklines read straight off the live /v1/public/stats payload.
  • UI Evidence section — left honestly incomplete: no GitHub-hosted screenshot URLs are attached (this session has no browser access to github.com to produce user-attachments/user-images URLs, and the template asks not to commit review-evidence images to the repo). See Notes for what was actually verified.
  • Public docs/changelogs are updated where needed; no changelog edit (not a release-prep PR).

Notes

Test coverage added:

  • test/unit/public-review-volume-trend.test.ts (9 tests): the cohort-bucketing pure function (accumulation across days in the same week, out-of-window rows ignored, unparseable day strings ignored, the MIN_REVIEW_VOLUME_TREND_SAMPLE null-guard on both sides of the boundary, default weeks param, empty-input all-zero buckets) and an end-to-end test proving a PR credits its publish week's cohort even when it merges in a later week, plus Orb-fleet folding across two directions of the ?? 0 fallback.
  • test/integration/public-stats-route.test.ts (extended): asserts reviewVolumeTrend rides along on the same response, with real numbers from the existing seed.
  • apps/gittensory-ui/src/components/site/proof-of-power-stats.test.tsx (updated): the "five headline stats" test's sparkline-count assertion is now 4 (all trend-eligible tiles), using an extended payload fixture.

UI Evidence — what was actually verified (real recharts render in a real browser DOM via Claude Code's Preview tooling, not a snapshot test; same method used for the original two sparklines):

  • Dark mode: all 4 sparklines render with the app's own existing --chart-1..--chart-4 ramp (verified via computed stroke matching the exact OKLCH values in styles.css), 2px stroke, round caps/joins.
  • Light mode: toggled the .dark class off directly (this app keys theming off a class, not prefers-color-scheme) — all 4 sparklines correctly repaint to their light-mode OKLCH values.
  • Mobile (375×812): the 2-column grid wraps correctly; all tiles and sparklines stay proportioned, no overflow.
  • Real seeded numbers (8,216 reviewed / 26.4% filtered / 100% accuracy / 84.5% reuse) rendered correctly across all 5 tiles.

…e hero sparklines (#4445 follow-up)

Extends GET /v1/public/stats with reviewVolumeTrend, mirroring #4447's
accuracy-trend design but bucketed as per-week COHORTS (a PR credits the
week it was first published, and `merged` reflects its current
disposition regardless of which week it actually merged) since
filteredPct only means anything against a fixed PR set.

Wires the homepage's remaining two headline tiles ("PRs reviewed",
"Filtered without merge") to their own 8-week sparklines, completing all
5 tiles. "Maintainer time saved" stays without one -- it's a fixed
multiple of PRs reviewed, so its own trend would just be a rescaled copy.
@JSONbored JSONbored self-assigned this Jul 10, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

1 similar comment
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.20%. Comparing base (8459098) to head (6601f41).
⚠️ Report is 7 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4722   +/-   ##
=======================================
  Coverage   94.19%   94.20%           
=======================================
  Files         437      438    +1     
  Lines       38574    38610   +36     
  Branches    14061    14068    +7     
=======================================
+ Hits        36336    36372   +36     
  Misses       1576     1576           
  Partials      662      662           
Files with missing lines Coverage Δ
src/api/routes.ts 94.26% <100.00%> (ø)
src/openapi/schemas.ts 100.00% <ø> (ø)
src/services/public-accuracy-trend.ts 100.00% <ø> (ø)
src/services/public-review-volume-trend.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
gittensory-ui 6601f41 Commit Preview URL

Branch Preview URL
Jul 10 2026, 08:44 PM

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 10, 2026
@loopover-orb

loopover-orb Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-10 20:47:03 UTC

10 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • Touches a guarded path — held for manual review: This PR changes guardrail-protected path(s): src/services/public-accuracy-trend.ts (matched src/services/**), src/services/public-review-volume-trend.ts (matched src/services/**).

Review summary
This PR adds a live-computed weekly review-volume/filtered-rate trend, wiring it through the service layer, OpenAPI schema, route, UI model, and UI sparklines, closing out the last two un-sparklined hero tiles. It closely mirrors the existing accuracy-trend and reuse-rate-trend patterns (reused `isoWeekStart`, exported `loadOrbDayRows` for reuse rather than duplicating it), and the cohort-vs-event-date design choice is well-reasoned and documented to stay consistent with the lifetime `totals.filteredPct` figure it mirrors. Tests are substantive (not fabricated): they exercise real day-boundary bucketing, the sample-size floor, and an end-to-end DB-backed cohort scenario where a PR published one week merges the next, and the reachable `?? 0` fallback branches are genuinely exercised while the unreachable SQL SUM fallback is honestly `v8 ignore`d rather than faked. I don't see a reachable correctness defect here.

Nits — 7 non-blocking
  • src/services/public-review-volume-trend.ts's loadOwnLedgerDayRows aggregates MIN/MAX over the entire audit_events history before the outer `HAVING date(first_seen) >= date(?)` discards everything outside the trailing 8 weeks — as the ledger grows this becomes an unbounded full scan; consider pushing a lower bound into the inner subquery's WHERE instead of filtering post-aggregation.
  • The bare `first_seen` reference in the outer `HAVING` clause (public-review-volume-trend.ts) relies on SQLite's implementation-defined column resolution after GROUP BY; it's correct today because every row in a `day` group shares the same `date(first_seen)`, but it's fragile to a future query reshape — consider `HAVING day >= date(?)` for clarity.
  • Multiple files reference 'Epic: public, tracked-over-time benchmarks for gittensory's own review engine (speed, accuracy trend, efficiency) #4445' in prose comments without a shared named constant tying the follow-up chain together (public-accuracy-trend.ts:139, public-review-volume-trend.ts header) — purely cosmetic.
  • src/api/routes.ts and openapi.json continue to grow past the repo's long-file threshold; not this PR's fault alone, but worth a follow-up split if either keeps accreting per-endpoint additions.
  • Bound loadOwnLedgerDayRows's inner subquery by sinceIso directly (e.g. add it to the existing WHERE alongside the repo IN-list) rather than relying on the outer HAVING, so the query cost stays proportional to the trailing window instead of total ledger size.
  • PR author also opened the linked issue — Link an issue that was opened by a different contributor, or provide a rationale for why this self-authored issue represents genuine discovery work.
  • Touches a guarded path — held for manual review — A maintainer must review and merge this change.
Signal Result Evidence
Code review ✅ No blockers 1 reviewer
Linked issue ✅ Linked #4721
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 48 registered-repo PR(s), 40 merged, 296 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 48 PR(s), 296 issue(s).
Gate result ⚠️ Not blocking Advisory; not blocking this PR.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 48 PR(s), 296 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before / after /
/ mobile before / (mobile) after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 10, 2026
@JSONbored
JSONbored merged commit bfc34cd into main Jul 10, 2026
13 checks passed
@JSONbored
JSONbored deleted the feat/public-review-volume-trend-4445followup branch July 10, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(stats): sparkline the remaining two homepage headline tiles (PRs reviewed, filtered %)

1 participant