Dashboard detail, library filtering/pagination, simplified playlist times,

job descriptions

Dashboard: format breakdown (FLAC/MP3/etc. counts), approximate library
size (bitrate*length/8, same approximation `beet stats` itself uses --
verified to match its "100.5 GiB" output exactly against the real
library), and a credential auth-state summary per scope (configured y/n
plus, for Bandcamp, cookie expiry parsed locally from the stored cookie
jar -- deliberately not a live network probe like pipeline-status.sh's
Qobuz check, since this renders on every dashboard load).

Library: was one unfiltered page dumping all 4072 tracks. Added search
(artist/title/album), playlist and format filter dropdowns, and real
SQL-level pagination (LIMIT/OFFSET, not fetch-everything-then-slice).
beets_service gained count_items()/distinct_formats() to support this.

Playlists: cron_expr is still the stored/scheduled representation, but the
UI now shows and edits a plain daily time picker instead of raw cron
syntax -- every playlist schedule today is a simple daily HH:MM anyway.
playlist_service.cron_to_time()/time_to_cron() convert at the router
boundary; verified round-trip against all real playlist cron values.

Jobs: each maintenance job now shows a short one-line description of what
it actually does (MAINTENANCE_JOB_DESCRIPTIONS), and "next run" is
formatted consistently with playlists' time style (HH:MM, with a day
qualifier for non-today runs -- maintenance jobs can be weekly/monthly,
unlike playlists' plain daily schedule).

Verified end-to-end against the real production data (4072 tracks, 100.5
GiB, real credentials): stats/format-breakdown/search/pagination all
correct, all 7 credential scopes report configured with Bandcamp's real
cookie expiry (325 days), and a full authenticated page-render sweep
(dashboard, library with every filter combination, playlist detail,
jobs) all returned 200 with no template errors.
This commit is contained in:
andrew
2026-07-08 15:39:22 -06:00
parent ee21251f3e
commit c87ddc2649
13 changed files with 355 additions and 34 deletions
+36
View File
@@ -182,3 +182,39 @@ def render_scope(db: Session, scope: str) -> None:
else:
raise ValueError(f"unknown credential scope: {scope}")
def _bandcamp_cookie_expiry(cookies_txt: str) -> float | None:
"""Parse the Netscape-format cookie jar for the 'identity' cookie's
expiry (Unix timestamp) -- same field pipeline-status.sh already reads
via `awk -F'\\t' '$6=="identity" {print $5}'`. Purely local string
parsing, no network call, safe to run on every dashboard load."""
for line in cookies_txt.splitlines():
fields = line.split("\t")
if len(fields) >= 6 and fields[5] == "identity":
try:
return float(fields[4])
except ValueError:
return None
return None
def auth_states(db: Session) -> list[dict]:
"""Per-scope credential health for the dashboard: whether it's
configured at all, plus (bandcamp only) cookie expiry -- computed
locally from the stored cookie jar, not a live network probe (unlike
pipeline-status.sh's Qobuz check, which hits Qobuz's API on every run;
deliberately not replicated here since the dashboard renders on every
page load)."""
states = []
for scope in SCOPE_FIELDS:
values = get_scope(db, scope)
configured = bool(values)
entry = {"scope": scope, "configured": configured}
if scope == "bandcamp" and values.get("cookies_txt"):
expiry = _bandcamp_cookie_expiry(values["cookies_txt"])
if expiry is not None:
entry["expires_at"] = expiry
entry["days_left"] = int((expiry - time.time()) / 86400)
states.append(entry)
return states