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
This commit is contained in:
parent
e819548ff2
commit
edbb6f088f
6 changed files with 134 additions and 36 deletions
|
|
@ -66,6 +66,7 @@ BASE_COLUMNS = """
|
|||
i.distinct_watcher_count, i.pre_history, i.kept, i.kept_via, i.kept_mark_id,
|
||||
i.provider_view_count, i.status, i.parent_id, i.season_number,
|
||||
i.provider_added_at, i.added_at_source, i.first_seen_at,
|
||||
i.provider_last_viewed_at,
|
||||
parent.title AS show_title
|
||||
"""
|
||||
|
||||
|
|
@ -224,6 +225,8 @@ class Query:
|
|||
"provider_added_at": d.get("provider_added_at"),
|
||||
"added_at_source": d.get("added_at_source"),
|
||||
"first_seen_at": d.get("first_seen_at"),
|
||||
"first_watched_at": d.get("first_watched_at"),
|
||||
"provider_last_viewed_at": d.get("provider_last_viewed_at"),
|
||||
"last_watched_at": d.get("last_watched_at"),
|
||||
"last_touched_at": d.get("last_touched_at"),
|
||||
"watch_count": d.get("watch_count") or 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue