Add media usage read query foundation#2075
Conversation
🦋 Changeset detectedLatest commit: 1b8dad1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Scope checkThis PR changes 878 lines across 7 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-playground | 1b8dad1 | Jul 16 2026, 02:12 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-cache | 1b8dad1 | Jul 16 2026, 02:13 PM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
emdash-demo-do | 1b8dad1 | Jul 16 2026, 02:14 PM |
There was a problem hiding this comment.
This is the right change for the stated goal: it lays down the internal, persistence-only query foundation for coverage-aware media usage reads, keeps all public surface (REST, client, OpenAPI, admin UI) out as promised, and follows the linked discussion. The migration is forward-only and idempotent, the composite index is justified by the query-plan tests, and the eligibility logic for draft-overlay vs. published columns is covered by focused repository tests.
I checked:
- Migration 052 index swap (create-new-then-drop-old) and its idempotency test.
- Runner registration and the expected-indexes list update.
- The new repository queries: batched active-entry counts, collection coverage status, and grouped entry pagination.
- Cursor/limit clamping, batch sizing, and locale handling (these methods query the projection tables, not
ec_*content tables, and each translation row is its owncontent_id, so no missing locale filter bug). - SQL safety: values are parameterized via Kysely; no interpolated identifiers.
- Tests: dialect-parity repository tests plus a SQLite/D1-plan test.
No blocking correctness or security issues. Two small opportunities to simplify/reduce work in the page query are noted.
What does this PR do?
Adds the internal query foundation for coverage-aware media usage reads. It batches active-entry counts, loads collection coverage, pages complete content-entry groups, and replaces the media-only occurrence index with a composite media/source/generation index justified by query-plan tests.
This PR intentionally adds no REST, client, OpenAPI, documentation, or admin UI surface. A follow-up PR will expose the complete read API after this foundation lands.
Related discussion: #1503
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
No visual changes.
main.Try this PR
Open a fresh playground →
A full working EmDash site, deployed from this branch. Each visit gets its own session-scoped sandbox: no login needed and no shared state. Try the admin, edit content, hit the public site.
Tracks
media-usage-read-queries. Updated automatically when the playground redeploys.