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:
@@ -8,6 +8,39 @@ from sqlalchemy.orm import Session
|
||||
from app.models import Playlist
|
||||
from app.settings import settings
|
||||
|
||||
|
||||
def cron_to_time(cron_expr: str | None) -> str:
|
||||
"""'30 1 * * *' -> '01:30'. Every playlist schedule today is a simple
|
||||
daily HH:MM (no day-of-week/day-of-month complexity -- that's only used
|
||||
by a couple of maintenance jobs), so the UI can offer a plain time
|
||||
picker instead of raw cron syntax. Returns '' for anything else
|
||||
(unscheduled, or a cron expression more complex than daily-at-HH:MM)."""
|
||||
if not cron_expr:
|
||||
return ""
|
||||
parts = cron_expr.split()
|
||||
if len(parts) == 5 and parts[2] == "*" and parts[3] == "*" and parts[4] == "*":
|
||||
try:
|
||||
hour, minute = int(parts[1]), int(parts[0])
|
||||
if 0 <= hour < 24 and 0 <= minute < 60:
|
||||
return f"{hour:02d}:{minute:02d}"
|
||||
except ValueError:
|
||||
pass
|
||||
return ""
|
||||
|
||||
|
||||
def time_to_cron(time_str: str | None) -> str | None:
|
||||
"""'01:30' -> '30 1 * * *'. Empty/invalid input means unscheduled."""
|
||||
if not time_str:
|
||||
return None
|
||||
try:
|
||||
hour_str, minute_str = time_str.split(":")
|
||||
hour, minute = int(hour_str), int(minute_str)
|
||||
except ValueError:
|
||||
return None
|
||||
if not (0 <= hour < 24 and 0 <= minute < 60):
|
||||
return None
|
||||
return f"{minute} {hour} * * *"
|
||||
|
||||
# The 17-entry array this project is migrating off of (was hardcoded in
|
||||
# /opt/sldl/configs/regen.sh). Used once by seed_legacy() during Stage 1/2
|
||||
# of the migration; the DB is the source of truth from then on. cron_expr
|
||||
|
||||
Reference in New Issue
Block a user