Skip to content

Fix maintainer dashboard 'Open PRs cached' undercount#408

Merged
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-undercounted-open-pr-metric
Jun 5, 2026
Merged

Fix maintainer dashboard 'Open PRs cached' undercount#408
JSONbored merged 1 commit into
mainfrom
codex/propose-fix-for-undercounted-open-pr-metric

Conversation

@JSONbored
Copy link
Copy Markdown
Owner

Motivation

  • The maintainer dashboard previously summed cached open PRs by filtering listRepoSyncStates(), but that helper is capped at 500 rows and can silently undercount repos whose sync-state rows fall outside the latest 500.
  • The intent is to provide a true global count across all in-scope repositories for the Open PRs cached headline metric.

Description

  • Add summarizeRepoSyncOpenPullRequests in src/db/repositories.ts that aggregates open_pull_requests_count directly from the repo_sync_state table using a SQL SUM and CASE expressions, and supports optional per-repo scoping; the implementation chunks names (450 per chunk) to avoid parameter limits and uses inArray from drizzle-orm.
  • Import inArray from drizzle-orm and expose the new helper from the DB module (src/db/repositories.ts).
  • Update the maintainer dashboard handler in src/api/routes.ts to call summarizeRepoSyncOpenPullRequests with the resolved in-scope repository list instead of filtering the capped listRepoSyncStates() result.
  • Add an integration test in test/integration/api.test.ts (counts cached open PRs from sync states beyond the latest 500 rows) that seeds an older sync-state row plus 500 newer rows and asserts the dashboard metric counts all of them.

Testing

  • Ran type checking with npm run typecheck and it succeeded.
  • Ran the focused integration tests with npx vitest run test/integration/api.test.ts -t "cached open PRs" and the tests passed (the targeted tests passed).
  • Ran git diff --check as part of validation and there were no whitespace/check errors.

Codex Task

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 5, 2026
@cloudflare-workers-and-pages
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 54c3c92 Commit Preview URL

Branch Preview URL
Jun 05 2026, 08:56 AM

@JSONbored JSONbored self-assigned this Jun 5, 2026
@JSONbored JSONbored merged commit 3cd4a7b into main Jun 5, 2026
8 checks passed
@JSONbored JSONbored deleted the codex/propose-fix-for-undercounted-open-pr-metric branch June 5, 2026 23:06
@github-project-automation github-project-automation Bot moved this from Todo to Done in gittensory - v1 roadmap Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aardvark codex size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant