Repository navigation
fix(admin): stop counting workflow runs on dashboard list pages - #9630
Merged
Merged
Conversation
The organizations and users lists counted each entity's distinct workflow executions alongside its spend. No entity index carries execution_id, so the count heap-fetched every workflow ledger row in each entity's period and the list grew past the statement timeout as the ledger grew. - Lists and the reporting-period preview read spend only (index-only) and return workflowRuns: null. - Organization detail counts runs once, total plus every actor's share in one GROUPING SETS scan, under a 5s budget via readLedgerBounded; past it the count is null and the page still loads. Former actors' runs come from the same scan. - The contract makes workflowRuns nullable.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
[Medium impact] The PR appears safe to merge; no new actionable issues remain. SummaryStops counting workflow runs on admin list pages and reporting-period previews. Organization details count runs within a five-second budget.
Reviews (2) · Last reviewed commit: "fix(admin): count former actors' runs on..." · Reviewed by Greptile |
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
Former actors' workflow runs were the sum of their per-user counts, so a run shared by two former actors counted twice. Group the same scan by a former-actor flag as well and read the distinct count from it. The flag tests membership against two uncorrelated lists, so each is hashed once. Also drop the last non-null assertion in the organizations list and shrink the explicit-any baseline.
Collaborator
Author
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
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
usage_logcarriesexecution_id, so that count heap-fetches every workflow ledger row in each entity's period, one statement for a whole page of entities. As the ledger grew the list went from seconds to past the 60s statement timeout.workflowRuns: null.GROUPING SETSscan, run alongside the page reads, under a 5s budget viareadLedgerBounded(new optionalbudgetMs). Past the budget the count isnulland the page still loads. Former actors' runs come from the same scan instead of a second heap pass.workflowRunsis nullable. The deployed admin app already rendersnullas—; a companion admin PR drops the list columns.execution_idwould grow the hot billing sums' working set for a staff-only number (left as a follow-up if staff need exact counts for the largest payers).Type of Change
Testing
lib/admin/dashboard-usage.integration.tsagainst real Postgres: spend per entity/user, runs total + per actor (shared run counts for each actor), empty entity, former-actor spend, and a run count blocked past its budget returnsnull(verified red with the guard removed)lib/admin/dashboard-organizations.test.ts,lib/api/contracts/v1/admin/dashboard.test.ts,lib/billing/**unit tests,lib/billing/core/ledger-read.integration.tsbun run lint,type-check(pre-push)EXPLAINof the new runs statement: presortedGroupAggregateover the period cost index, no extra sortChecklist
test-auditauthoring gate)