siftlode/backend/app/routes
npeter83 28061353ec Plex backend pass (#9): watch_sync bugs + backend dedup
Closes the Plex #9 backend backlog (frontend was the prior follow-up). Behavior-
neutral cleanup + two two-way-sync bug fixes; PW2 verified a non-bug.

fix(plex): watch-sync PW1 pagination + PW3 lost-update guard
- PW1 watch_history: the history is a GLOBAL cross-account feed read as a single
  500-row page, then filtered to the owner — on a busy family server the owner's
  recent views can sit past page 1 and be missed. Now paginate (desc) until the
  since-cutoff, bounded by max_pages (daily reconcile is the backstop; logs if hit).
- PW3 push_state_to_plex: it flagged synced_to_plex=True unconditionally after a
  push, so a local edit landing between the push and the flag-set was marked clean
  and never pushed (lost update). Capture the row's freshest timestamp when the
  push is scheduled (_push_watch) and only settle the flag if the row is unchanged.
- PW2 was flagged as "accountID hardcoded to 1" but is NOT a bug: on a PMS account 1
  is reserved for the owner/admin and an owner link always holds the admin token —
  added a clarifying comment so it isn't re-flagged.

chore(plex): backend dedup
- PC2 unified_library + facets shared a ~13-field filter Query signature + p-dict →
  one LibraryFilters dataclass injected via Depends(); as_dict() feeds the builders.
- PS-C1 sync.py collection upsert dup (resync_collection ≈ _sync_collections) →
  _upsert_collection().
- PS-C2 sync.py 8-field filterable-metadata block dup (_apply_item ≈ _sync_shows) →
  _apply_facet_fields().
- PW-C1 _repush_dirty read duration from the mirrored PlexItem.duration_s instead of
  a per-row plex.metadata() round-trip.
- PW-C2 rk→id map built inline in two places → _rk_to_id() helper.
2026-07-11 23:48:35 +02:00
..
__init__.py feat: M1 foundation — compose stack, FastAPI, Google OAuth, encrypted tokens 2026-06-11 01:01:37 +02:00
admin.py fix(auth): last-admin guard counts only ACTIVE admins (prevents lockout) 2026-07-11 21:26:39 +02:00
channels.py chore(channels): Phase 2 #3 backend cleanup — extract blocked + summary helpers 2026-07-11 18:11:23 +02:00
config.py feat(config): DB-backed system_config infrastructure + SMTP group 2026-06-19 12:22:36 +02:00
downloads.py Merge branch 'dev' into chore/code-hygiene 2026-07-11 16:22:39 +02:00
feed.py chore(feed): Phase 2 #2 backend cleanup — dead return, dup helpers, shared const 2026-07-11 17:37:52 +02:00
health.py feat: M1 foundation — compose stack, FastAPI, Google OAuth, encrypted tokens 2026-06-11 01:01:37 +02:00
me.py fix(auth): security hardening — token encryption, timing, adoption + isolation 2026-07-11 21:26:39 +02:00
messages.py feat(auth): per-tab account — different account per browser tab 2026-07-01 23:43:35 +02:00
notifications.py feat(notifications): durable per-user inbox (P1) + maintenance schema 2026-06-18 03:20:17 +02:00
playlists.py fix(playlists): reorder position collision + dedup remove helper 2026-07-11 18:33:16 +02:00
plex.py Plex backend pass (#9): watch_sync bugs + backend dedup 2026-07-11 23:48:35 +02:00
public.py chore(downloads): C3-C6 — DRY the source-URL, filename, and serialize helpers 2026-07-11 05:47:51 +02:00
quota.py feat(stats): per-user API quota attribution + admin usage page 2026-06-12 02:47:55 +02:00
saved_views.py feat(views): saved-views backend — table, model, CRUD + reorder API 2026-07-01 03:17:36 +02:00
scheduler.py feat(config): move operational params to DB (quota/backfill/shorts/batch) 2026-06-19 13:07:45 +02:00
search.py fix(feed): repair 2 bugs found in the Phase 2 #2 review 2026-07-11 17:43:18 +02:00
setup.py feat(setup): install-wizard step endpoints (epic 6c, API) 2026-06-21 00:40:54 +02:00
sync.py refactor(backend): quota.measured helper, consistent admin gating, messageable predicate 2026-06-26 03:15:53 +02:00
tags.py refactor(auth): centralize token hashing, email validation & admin gating 2026-06-26 03:15:36 +02:00
version.py feat(version): /api/version + build-time version/commit stamping 2026-06-15 00:06:57 +02:00