- Restore synchronize_session=False on the remove-bulk Core delete (the 2.0 default is 'auto'; keep the pre-conversion contract explicit). - _episode_nav: list(...scalars()) instead of [r[0] for r in ...all()], matching the house style used across the conversion. - Extract app/plex/lookups.by_rating_key() and migrate the get-by-rating_key pattern at 13 sites (imgcache x4, _shared.item_or_404, playback show/season, browse x6). - Coverage: add TestFacetsWithData (the converted wsq aggregation with real data — the highest-risk untested builder), TestPlaylistAndCollectionEndpoints (playlist CRUD + collections list), and an item-state playback test. Full suite 256 passed, 2 skipped; ruff clean.
21 lines
505 B
Python
21 lines
505 B
Python
"""Shared helpers, serializers and constants for the plex route package."""
|
|
|
|
import logging
|
|
|
|
from fastapi import HTTPException
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.models import (
|
|
PlexItem,
|
|
)
|
|
from app.plex.lookups import by_rating_key
|
|
|
|
log = logging.getLogger("siftlode.plex")
|
|
|
|
|
|
def item_or_404(db: Session, rating_key: str) -> PlexItem:
|
|
it = by_rating_key(db, PlexItem, rating_key)
|
|
if it is None:
|
|
raise HTTPException(status_code=404, detail="Unknown Plex item")
|
|
return it
|