siftlode/backend/app/routes
npeter83 940b616804 fix(player): persist watched at end-of-playback (atomic upsert)
The in-app player marks a video watched when it reaches the end, firing
POST /videos/{id}/state at the same instant as a progress checkpoint. The
progress endpoint deletes the 'new' video_states row near the end, so the
concurrent state UPDATE matched 0 rows and raised StaleDataError -> 500. The
watched status was never persisted (and Feed swallowed the error), so the
video stayed in the unwatched feed even after a refresh.

- set_video_state: atomic INSERT ... ON CONFLICT (uq_user_video) DO UPDATE for
  watched/hidden, immune to a concurrent delete; tolerate StaleDataError on the
  'new' branch and in the progress endpoint.
- PlayerModal: skip the redundant near-end progress checkpoint when we just
  auto-marked watched, removing the self-inflicted race.
- Feed: drop the optimistic override if the server rejects the change, so a
  failed request can't leave a card phantom-hidden.
2026-06-17 13:38:47 +02:00
..
__init__.py feat: M1 foundation — compose stack, FastAPI, Google OAuth, encrypted tokens 2026-06-11 01:01:37 +02:00
admin.py feat(demo): admin demo whitelist CRUD + state reset 2026-06-16 09:17:27 +02:00
channels.py feat(stats): per-user API quota attribution + admin usage page 2026-06-12 02:47:55 +02:00
feed.py fix(player): persist watched at end-of-playback (atomic upsert) 2026-06-17 13:38:47 +02:00
health.py feat: M1 foundation — compose stack, FastAPI, Google OAuth, encrypted tokens 2026-06-11 01:01:37 +02:00
me.py feat(demo): hidden /auth/demo login + require_human guard 2026-06-16 09:17:21 +02:00
playlists.py feat(playlists): derive dirty from a synced-state fingerprint 2026-06-15 23:00:56 +02:00
quota.py feat(stats): per-user API quota attribution + admin usage page 2026-06-12 02:47:55 +02:00
scheduler.py feat(scheduler): admin-editable job intervals (DB-backed, live reschedule) 2026-06-16 15:58:23 +02:00
sync.py feat(demo): hidden /auth/demo login + require_human guard 2026-06-16 09:17:21 +02:00
tags.py feat(m5a): channel manager, tabbed settings panel, per-user sync status 2026-06-11 20:45:48 +02:00
version.py feat(version): /api/version + build-time version/commit stamping 2026-06-15 00:06:57 +02:00