Skip to content

feat: paginate subscription group memberships - #86

Merged
Priveetee merged 6 commits into
TypeType-Video:devfrom
kapdon:codex/subscription-group-pagination
Sep 23, 2026
Merged

Priveetee merged 6 commits into
TypeType-Video:devfrom
kapdon:codex/subscription-group-pagination

Conversation

@kapdon

@kapdon kapdon commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Summary

The subscription group manager currently waits for the complete membership projection before displaying a page. Add an API that filters, counts and paginates in PostgreSQL, then loads memberships and repairs avatars only for the returned channels.

Required by TypeType-Frontend #32, following the pagination review. Refs TypeType #172.

  • GET /subscriptions/group-memberships/page: zero-based page, limit (1–100), literal substring search, named/ungrouped/inverted membership filters, matching total and account-wide subscription/ungrouped counts. Order is lowercase name, then canonical URL. Offset pages reflect current results; they are not a cross-request snapshot.
  • POST /subscriptions/group-memberships/lookup: read-only refresh of explicitly selected subscriptions retained across pages. Reuses the existing 500-URL, 2048-character and 1 MiB request limits, canonicalizes/deduplicates URLs and omits missing or foreign subscriptions.
  • Retain the legacy full-array endpoint for existing clients. Aggregate group counts in SQL instead of loading every membership row.
  • Use correlated membership existence checks for included, excluded and ungrouped filters. Normalize both the search input and stored values in PostgreSQL while preserving literal wildcard escaping.
  • Document both endpoints in OpenAPI and add route/service tests covering 25,000 channels with 112,500 memberships, stable page boundaries, Unicode search and escaping, all membership filters, ownership, missing groups, authentication and lookup limits.
  • Let tests use an explicitly supplied TEST_DATABASE_URL, with pg_trgm installed in the shared test search path for repeat runs. The default Testcontainers setup remains available.

Validation

./gradlew test shadowJar validateOpenApi check with JDK 25 and an isolated local PostgreSQL 16 database. 1,251 passed, 3 skipped against dev at 302b76e5; build, OpenAPI validation and coverage checks passed. Test libraries emit existing native-access/Unsafe runtime warnings.

Companion frontend behavior was checked in Chromium with a 150-channel fixture: bounded page requests, retained selections/drafts, membership search and inversion, last-page adjustment, and failed selection-refresh recovery. Firefox/WebKit and a browser session against the running Kotlin server remain unverified.

No new dependencies or database migrations. Each commit has fewer than 300 insertions.

@Priveetee

Copy link
Copy Markdown
Member

Hey @kapdon, thx again for this PR! The SQL pagination and the test coverage look exactly like what we need for large subscription lists! :)

Before I start the full review, the branch needs an update: dev now uses the modular server layout, so the PR currently conflicts with the old single-module paths.

Mainly, the files need to move to their owning modules:

  • SubscriptionMembershipPage.kt -> server-core
  • SubscriptionMembershipPageRoutes.kt -> server-http
  • SubscriptionGroupQueries.kt, SubscriptionMembershipFilter.kt and SubscriptionMembershipPageService.kt -> server-services
  • the tests -> the matching module source sets
  • TestDatabase -> the one from server-db test fixtures

No pagination changes expected here. If it’s easier for u, I can handle that update myself, no worries at all! Just tell me what u prefer. Once the branch is clean against dev, I’ll review it :)

@kapdon
kapdon force-pushed the codex/subscription-group-pagination branch from d245874 to 57b6e7a Compare September 23, 2026 06:34
@kapdon

kapdon commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

ok should be good now

@Priveetee

Copy link
Copy Markdown
Member

Thank you for the tremendous amount of work you put into this PR! I really appreciate the effort behind the pagination and membership changes :)

I pushed a small follow-up to improve search performance and concurrent reads: trigram indexes for subscription search, shared locks for membership reads while preserving exclusive write locks, and read-only avatar enrichment. I also added tests for search scale, reader/writer concurrency, and avatar enrichment.

I ran the full test suite, check, and shadowJar; the PR’s build, coverage, and OpenAPI checks are all passing. LGTM from my side! I’ll merge it into dev :)

@Priveetee
Priveetee merged commit 576a024 into TypeType-Video:dev Sep 23, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants