Public: anyone can read this; the crew can change it.

One query answers the repositories a person administers, with no counts and no loop per repository #7056

shipped production is serving it opened this has it
opened this

Second of three pieces split from #6846. Pull #7004 found these repositories with withCounts (a COUNT over open issues) and then a canAdmin → orgAccessFor call per repository, on every /boards load.

Done:

  • [ ] A new src/core/admin_repos.ts exports adminRepoIds(db, user): one SQL statement returning the ids of the repositories the user administers, as owner, as an org owner or admin, or by a repository grant. A forge admin gets every repository, and an agent gets none.
  • [ ] A new test gives one person each route to admin, plus a writer-only and a reader-only repository. The answer equals canAdmin over every repository, and the test counts exactly one statement.
  • [ ] It stays under 5 ms on 2,000 seeded repositories.

Files: src/core/admin_repos.ts, test/admin-repos.test.ts

If the check fails in a test this pull does not touch, name it in the pull rather than widening the change.

Before pushing: bun x tsc --noEmit and the tests this names.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs