Scene.duration_sec was NULL for ~74% of playable scenes (tube duration lives on playback_source, never propagated to Scene), so the mobile min_duration_sec=60 filter (Scene.duration_sec >= 60; NULL fails) silently hid them — surfaced as '119 in favorites, 14 after entering the performer' (Safira Yakkuza). - resolver: _effective_duration() falls back to max live playback_source duration when the connector provides no scene-level duration (forward fix, used in create + update). - scripts/backfill_scene_duration_from_playback.py: one-off idempotent backfill (recovered 204,014 scenes). - taxonomy_counts: scene_count now counts playable AND duration_sec >= 60, matching the always-60s-filtered scene lists, so favorites/performer/studio/tag badges agree with what the scene screen actually shows (Safira: 39 == 39). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
"""Backfill Scene.duration_sec z live playback_source, gdzie Scene NULL.
|
|
|
|
Tube'y zapisują duration na playback_source, a nie na Scene → 74% grywalnego katalogu
|
|
miało Scene.duration_sec=NULL → mobilny filtr `min_duration_sec=60` (Scene.duration_sec
|
|
>= 60; NULL >= 60 = false) chował te sceny mimo że są grywalne i długość jest znana
|
|
(bug-report 2026-06-01 Safira Yakkuza: 119 w ulubionych, 14 po wejściu).
|
|
|
|
Propagacja forward jest w resolverze (`_effective_duration`); ten skrypt nadrabia
|
|
istniejące. Idempotentny — ustawia tylko wiersze z NULL.
|
|
|
|
Użycie: python scripts/backfill_scene_duration_from_playback.py
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
import sys
|
|
|
|
from sqlalchemy import text
|
|
|
|
from app.db import session_scope
|
|
|
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
|
log = logging.getLogger("backfill_duration")
|
|
|
|
_SQL = text(
|
|
"""
|
|
UPDATE scenes sc
|
|
SET duration_sec = sub.d
|
|
FROM (
|
|
SELECT scene_id, max(duration_sec) AS d
|
|
FROM playback_sources
|
|
WHERE dead_at IS NULL AND duration_sec IS NOT NULL
|
|
GROUP BY scene_id
|
|
) sub
|
|
WHERE sc.id = sub.scene_id AND sc.duration_sec IS NULL
|
|
"""
|
|
)
|
|
|
|
|
|
def main() -> int:
|
|
with session_scope() as session:
|
|
res = session.execute(_SQL)
|
|
log.info("DONE: backfilled Scene.duration_sec for %d scenes", res.rowcount or 0)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|