refactor: R12 S3 — invert scheduler->routes, publish cross-module privates
Layering cleanup, no behaviour change (ruff clean backend+scripts, pytest 193): - Invert the scheduler->routes dependency: reset_demo_state (+ its demo-seed helpers) move from routes/admin.py to a new service module app/demo.py. Both routes/admin.py and scheduler.py now import it from app.demo, so the scheduler no longer reaches into the routes layer — its lazy import (the routes<->scheduler cycle workaround) is gone, hoisted to a top-level import. - Publish the private symbols that were imported across module boundaries (the underscore convention was lying): feed._serialize -> serialize, feed._to_tsquery_str -> to_tsquery_str, videos._insert_stubs -> insert_stubs, videos._stub_from_playlist_item -> stub_from_playlist_item, worker._uploader_url -> uploader_url, plex._shared._item_or_404 -> item_or_404. Scoped renames — the 5 other route modules keep their own truly private _serialize helpers. - _release_asset moves from routes/downloads.py to app/downloads/service.py as the public release_asset (asset bookkeeping is a service concern); the routes call it via service.release_asset.
This commit is contained in:
@@ -74,7 +74,7 @@ def enrich_row_people(db: Session, row, cast: list[dict]) -> bool:
|
||||
# items in the same batch: SessionLocal is autoflush=False, so the ORM query above can't see a
|
||||
# same-batch pending insert, and this path also races the concurrent info-page enrichment. The
|
||||
# Core execute runs immediately (not deferred to the caller's commit), so a later row in the
|
||||
# batch sees the row and skips it. Mirrors app/sync/videos.py:_insert_stubs.
|
||||
# batch sees the row and skips it. Mirrors app/sync/videos.py:insert_stubs.
|
||||
db.execute(
|
||||
pg_insert(PlexPerson)
|
||||
.values([{"name": nm, "photo_thumb": th} for nm, th in missing.items()])
|
||||
|
||||
Reference in New Issue
Block a user