goon/app/api
jtrzupek 5ae5dbb201 perf(scenes): bounded count + has_more for filtered scene lists
Filtered /scenes (tag/origin/q/studio/performer) ran exhaustive COUNT with
stub-filter EXISTS over 1.7M rows: TAG 5.1s, ORIGIN 4.9s, SEARCH 3.1s.
Mobile relied on `loaded < total` for infinite-scroll, making exact count
mandatory and ruling out approximate shortcuts.

Backend:
- SceneListOut gains has_more (bool) and total_capped (bool), both optional
  for backward compat with old mobile
- Filtered count uses LIMIT _COUNT_CAP+1 (1000) subquery — cost is
  O(min(matches, cap)) instead of O(all). Measured: TAG 5.1s→664ms,
  SEARCH 3.1s→138ms, ORIGIN 4.9s→1.07s (also fixes SiteScenes showing
  global count ~1M instead of per-site count)
- has_more from fetching per_page+1 rows (essentially free); extra row
  stripped before serialisation
- Pure-default list (no filters at all) keeps TTL-cached full count

Mobile:
- getNextPageParam uses has_more ?? fallback to loaded<total
- Display shows "{total}+" when total_capped=true (5 screens)

Verified on emulator: tag "Big Tits" → "1000 scenes" loaded, no 500s,
backward compat confirmed (old APK works against new backend).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-31 19:24:26 +02:00
..
__init__.py Initial commit 2026-05-20 10:10:22 +02:00
admin.py Initial commit 2026-05-20 10:10:22 +02:00
admin_html.py Initial commit 2026-05-20 10:10:22 +02:00
blacklist.py Initial commit 2026-05-20 10:10:22 +02:00
bug_reports.py Initial commit 2026-05-20 10:10:22 +02:00
expo_updates.py session work: bug-report fixes + WIP cleanup 2026-05-25 22:02:52 +02:00
favorites.py perf(taxonomy): denormalize scene_count for tags/performers/studios 2026-05-31 17:53:48 +02:00
movies.py feat(movies): watched/continue-watching tracking end-to-end 2026-05-28 23:24:06 +02:00
playback.py session work: bug-report fixes + WIP cleanup 2026-05-25 22:02:52 +02:00
scene_favorites.py Initial commit 2026-05-20 10:10:22 +02:00
scenes.py perf(scenes): bounded count + has_more for filtered scene lists 2026-05-31 19:24:26 +02:00
schemas.py perf(scenes): bounded count + has_more for filtered scene lists 2026-05-31 19:24:26 +02:00
seo.py feat(seo): public HTML SEO router + templates; add CLAUDE.md; ignore .nimbalyst 2026-05-31 16:29:59 +02:00
sources.py session work: bug-report fixes + WIP cleanup 2026-05-25 22:02:52 +02:00
stream_proxy.py session work: bug-report fixes + WIP cleanup 2026-05-25 22:02:52 +02:00
taxonomies.py perf(taxonomy): denormalize scene_count for tags/performers/studios 2026-05-31 17:53:48 +02:00
watch.py feat(movies): watched/continue-watching tracking end-to-end 2026-05-28 23:24:06 +02:00