Fix M3U write permission failure; add recently-downloaded section to dashboard
Playlist M3U regen now writes to a temp file and renames it into place, so a stray wrong-owner leftover file (root:root, from pre-migration host-cron runs) can't block nightly writes the way it did last night. Dashboard now lists tracks added to the beets library in the last 24h with playlist and format, sourced from a new beets_service.recently_added().
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import time
|
||||
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from sqlalchemy import select
|
||||
@@ -10,6 +12,8 @@ from app.services import beets_service, credential_service, playlist_service
|
||||
router = APIRouter(tags=["dashboard"])
|
||||
templates = Jinja2Templates(directory="app/templates")
|
||||
|
||||
_RECENT_TRACKS_WINDOW_SECONDS = 24 * 60 * 60
|
||||
|
||||
|
||||
def _human_bytes(n: int) -> str:
|
||||
size = float(n)
|
||||
@@ -27,6 +31,7 @@ async def dashboard(request: Request, user: dict = Depends(require_auth), db=Dep
|
||||
recent_runs = list(
|
||||
db.execute(select(JobRun).order_by(JobRun.started_at.desc()).limit(10)).scalars()
|
||||
)
|
||||
recent_tracks = beets_service.recently_added(time.time() - _RECENT_TRACKS_WINDOW_SECONDS)
|
||||
return templates.TemplateResponse(
|
||||
request,
|
||||
"dashboard.html",
|
||||
@@ -37,6 +42,7 @@ async def dashboard(request: Request, user: dict = Depends(require_auth), db=Dep
|
||||
"playlist_count": len(playlists),
|
||||
"active_playlist_count": len([p for p in playlists if p.active]),
|
||||
"recent_runs": recent_runs,
|
||||
"recent_tracks": recent_tracks,
|
||||
"auth_states": credential_service.auth_states(db),
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user