feat(approvals): approver join table — exact pushdown for approver-filtered pagination#1782
Merged
Merged
Conversation
…ltered pagination (#1745) sys_approval_approver holds one row per (pending request, approver identity); the service mirrors every pending_approvers change into it and clears rows when a request leaves pending. listRequests / countRequests resolve approver filters through the index and push status arrays down as $in, so pages and totals are correct at any table size — the 500-row bounded-scan residual is gone. rebuildApproverIndex() backfills idempotently at plugin start. Closes #1745 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Summary
The follow-up half of #1745 (server-side pagination landed in #1764).
pending_approversstayed a CSV column, so approver-filtered queries ("my pending") were still a post-filter over a bounded 500-row scan — correct for personal queues, wrong for org-wide approver queries past the window.sys_approval_approverobject — one row per (pending request, approver identity: user id / email /role:*literal). Indexed on(approver, organization_id)and(request_id). The table only holds the live work queue: rows are cleared when a request leavespending, so size tracks open approvals, not the append-only request history.pending_approvers(open / decide incl. unanimous partials / recall / send-back incl. auto-reject / reassign / SLA-escalate) mirrors the change into the index via a diff-basedsyncApproverIndex.listRequests/countRequestsresolve approver filters to request ids through the index ($inon indexed equality replaces the per-row CSV scan), and status arrays now push down as$in. Every filter is engine-side, solimit/offsetand totals are exact at any table size; the documented 500-row residual is gone.rebuildApproverIndex()rebuilds the index from the CSV source of truth (drops orphans/stale/duplicate rows, inserts missing ones) and runs idempotently onkernel:ready, so rows written before the index existed become queryable after one boot.pending_approversstays the human-readable source of truth;sys_approval_requestindex comment updated accordingly.No API contract change —
IApprovalService.listRequests/countRequestssignatures and the REST surface are untouched.Tests
$inpushdownrebuildApproverIndex: legacy backfill, orphan + stale-entry cleanup, idempotence90/90 package tests green, build green.
Closes #1745
🤖 Generated with Claude Code