- 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.
12 lines
492 B
Python
12 lines
492 B
Python
"""Small shared Plex row lookups, so the get-by-rating_key pattern lives in one place."""
|
|
from sqlalchemy import select
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
|
def by_rating_key(db: Session, model, rating_key: str):
|
|
"""The mirrored row for a Plex rating_key, or None. `model` is any of the rating_key-keyed Plex
|
|
tables (PlexItem / PlexShow / PlexSeason / PlexCollection)."""
|
|
return db.execute(
|
|
select(model).where(model.rating_key == str(rating_key))
|
|
).scalars().first()
|