MediaShelf/mediashelf
Jess Hallsworth edbb6f088f
Use Plex's lastViewedAt for the date correction, not just Tautulli
The correction shipped in the previous commit fired zero times on the live
library. It compared Plex's addedAt against MediaShelf's first completed
Tautulli play, but Tautulli history only starts 2025-03-08 and the wrong dates
are overwhelmingly older than that. The evidence that proved the bug in the
first place was Plex's own lastViewedAt - which the provider parsed and then
dropped on the floor.

Now stored as provider_last_viewed_at and folded into the bound:
added_at = MIN(provider_added_at, first_watched_at, provider_last_viewed_at).
Seasons also get their own provider_added_at (MIN over episodes), without which
their added_at_source could never be computed.

Fixture gains the case that actually failed: added last week, last viewed 1500
days ago, no Tautulli history at all - so only lastViewedAt carries it. Also
tightened test_correction_leaves_unwatched_items_alone, which defined
"unwatched" as watch_count=0 and so wrongly expected an item with Plex view
evidence to be left alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GVbG48GAXfCZatcmX123Ra
2026-09-10 17:49:20 +00:00
..
migrations Use Plex's lastViewedAt for the date correction, not just Tautulli 2026-09-10 17:49:20 +00:00
providers Stop dropping seasons Plex reports without a parentRatingKey 2026-09-10 14:37:30 +00:00
static Stop trusting Plex's Date Added on its own 2026-09-10 17:35:48 +00:00
templates Implement MediaShelf v1 2026-09-07 14:59:03 +00:00
__init__.py Implement MediaShelf v1 2026-09-07 14:59:03 +00:00
api.py Fix false "Plex fallback" banner during the first scan 2026-09-10 14:30:09 +00:00
app.py Implement MediaShelf v1 2026-09-07 14:59:03 +00:00
cli.py Implement MediaShelf v1 2026-09-07 14:59:03 +00:00
config.py Implement MediaShelf v1 2026-09-07 14:59:03 +00:00
db.py Implement MediaShelf v1 2026-09-07 14:59:03 +00:00
ingest.py Use Plex's lastViewedAt for the date correction, not just Tautulli 2026-09-10 17:49:20 +00:00
keeps.py Implement MediaShelf v1 2026-09-07 14:59:03 +00:00
queries.py Use Plex's lastViewedAt for the date correction, not just Tautulli 2026-09-10 17:49:20 +00:00
rules.py Stop trusting Plex's Date Added on its own 2026-09-10 17:35:48 +00:00
scanner.py Implement MediaShelf v1 2026-09-07 14:59:03 +00:00
scoring.py Implement MediaShelf v1 2026-09-07 14:59:03 +00:00
web.py Implement MediaShelf v1 2026-09-07 14:59:03 +00:00