Files
siftlode/backend/app/routes/plex/_shared.py
T
peter 3b0e365e26 refactor(plex): the browse, detail, people and collection pages read through queries and write through the service
The HTTP files browse, detail, people, collections and _shared do no database work of their own
now. New plex/queries.py (the rows a page shows, a user's watch state through userscope),
plex/service.py (the info pages' enrichment, a collection's editable flag, the row kept after a
failed follow-up read, the person bio's background fetch; none commits), plex/library.py (the
unified browse feed, its search and facets) and plex/collections.py (a collection's source,
editability, card, certificate and member order). Every watch-state join in the moved code names
its owner through owned_by.

Pins 354 -> 178 in 4 files; basedpyright baseline 132 -> 118.
2026-10-19 22:11:20 +02:00

23 lines
599 B
Python

"""Shared helpers, serializers and constants for the plex route package."""
from typing import TYPE_CHECKING
from sqlalchemy.orm import Session
from app import logs
from app.plex import queries
from app.plex.cards import norm_lang as _norm_lang # noqa: F401 — the package's historic name
from app.routes._common import not_found
if TYPE_CHECKING:
from app.plex.models import PlexItem
log = logs.get_logger(__name__)
def item_or_404(db: Session, rating_key: str) -> "PlexItem":
it = queries.item(db, rating_key)
if it is None:
raise not_found("plex_item")
return it