Fix false "Plex fallback" banner during the first scan
history_coverage is only written at the end of an ingest, but has_completion_data was reading from it. During the first scan the coverage table is empty while watch_event already holds tens of thousands of Tautulli rows, so the dashboard announced a fallback that had not happened and claimed the rejection component was disabled when it was not. The flag now comes from the events themselves — does any row carry a percent_complete — which is true the moment Tautulli rows land and false for Plex-only history. history_source falls back to the scan record when coverage is absent, so it reads "tautulli" mid-scan instead of null. Also: the banner named Plex as the source without checking, and now reports whichever source is actually active, and stays quiet while a scan is running since the counts are still moving. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GVbG48GAXfCZatcmX123Ra
This commit is contained in:
parent
a842aeb344
commit
71cfa31f09
4 changed files with 55 additions and 10 deletions
|
|
@ -182,3 +182,28 @@ def test_bulk_keep(client, scanned):
|
|||
assert r.status_code == 200
|
||||
assert r.get_json()["created"] == len(ids)
|
||||
assert client.get("/api/v1/keeps").get_json()["kept_items"] >= len(ids)
|
||||
|
||||
|
||||
def test_completion_flag_comes_from_events_not_the_coverage_table(client, scanned):
|
||||
"""history_coverage is written at the END of an ingest. Reading the flag from
|
||||
it made the UI announce a Plex fallback mid-scan on every fresh database."""
|
||||
from mediashelf import queries
|
||||
|
||||
assert queries.history_has_completion(scanned) is True
|
||||
|
||||
# simulate mid-scan: events present, coverage not yet written
|
||||
scanned.execute("DELETE FROM history_coverage")
|
||||
assert queries.history_has_completion(scanned) is True, \
|
||||
"flag went false with events already ingested"
|
||||
assert queries.active_history_source(scanned) == "tautulli", \
|
||||
"source should fall back to the scan record when coverage is absent"
|
||||
|
||||
ov = client.get("/api/v1/stats/overview").get_json()
|
||||
assert ov["has_completion_data"] is True
|
||||
assert ov["history_source"] == "tautulli"
|
||||
|
||||
|
||||
def test_completion_flag_is_false_for_plex_only_history(scanned):
|
||||
from mediashelf import queries
|
||||
scanned.execute("UPDATE watch_event SET percent_complete = NULL")
|
||||
assert queries.history_has_completion(scanned) is False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue