feat(code-review): dedicated Code Review section with analytics and org-wide review rules - #1211
Confidence 4/5 · No issues found
🟢 Confidence 4/5 · likely safe to merge
The new reads are org-scoped and cursor-paged with PGlite tests over totals, windows, paging and tenant isolation; the only defect is the author filter's eight-option cap.
quality 98/100 · 1 note · tests covered · risk medium · 1/2 new units observable
Adds a Code Review section served by a new org-scoped codeReview HttpApi group backed by Postgres aggregates over pr_reviews/pr_review_findings, with the author filter fix and the analytics window cap in this iteration. Safe to merge; one small gap in the author filter.
PrReviewAnalyticsServiceserves analytics, org-wide review list, review detail and findings, cursor-pagedCodeReviewFiltersloads the window's authors itself, so every tab can filter by one- List routes reset
limitonly for patches other thanreview, keeping loaded rows - Analytics start moves up to 366 days before
endTime, bounding the bucket series
Findings
🔵 Note · F3 · CodeReviewFilters offers only the window's top 8 authors
correctness · apps/web/src/components/code-review/code-review-layout.tsx:150-166
The Author select is built from analytics.authors, which the service caps at TOP with .limit(TOP) (packages/backend/src/services/pr-review/PrReviewAnalyticsService.ts:422). In an organization with more than eight PR authors in the window, the ninth and beyond can never be picked: the tab's own query would return their rows, but the filter holds no option for them, and the "Clear filters" empty state is the only way back.
Give the filter list its own bound larger than the leaderboard's `TOP` (or a dedicated authors query), so every author with a review in the window is selectable.
Fixed since the last review
- ✅
F2 · Opening a review's sheet resetslimit, collapsing the loaded pages
What was checked
- Bucket keys: SQL
floor(epoch/width)*width*1000and the JSMath.floor(startTime/bucketMs)agree on exact epoch ms MAX_SPAN_MSbounds the series to ≤53 buckets; the new test coversstartTime: 0- Tenant scoping: every new query filters
OrgId;getReviewflips NotFound for another org
Observability coverage: 1 of 2 changes observable
| Change | Kind | Observable | Evidence |
|---|---|---|---|
| GET /api/code-review/{analytics,reviews,reviews/:reviewId,findings} | http entrypoint | yes | CodeReviewApiGroup is served like the other org groups; each PrReviewAnalyticsService method is an Effect.fn annotated with orgId and maple.* attributes |
Postgres reads in PrReviewAnalyticsService (10 analytics queries, list, detail, findings) |
database | no | runs through makeDbExecute/drizzle without a per-query span or db.system/peer.service, matching the repo's existing drizzle call sites |
79e3bdb · Updated on every push. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.
Annotations
Check notice on line 166 in apps/web/src/components/code-review/code-review-layout.tsx
maple-review-bot / Maple / review
correctness: `CodeReviewFilters` offers only the window's top 8 authors
The Author select is built from `analytics.authors`, which the service caps at `TOP` with `.limit(TOP)` (`packages/backend/src/services/pr-review/PrReviewAnalyticsService.ts:422`). In an organization with more than eight PR authors in the window, the ninth and beyond can never be picked: the tab's own query would return their rows, but the filter holds no option for them, and the "Clear filters" empty state is the only way back.