feat(tracks): filter track list by ingest source
Add an optional `source` filter to `GET /api/v1/tracks` (and the `TrackRepository.list`/`count` port + SQLAlchemy adapter). Lets clients query, e.g., only uploaded tracks (`?source=upload`) newest-first — the backing for the webui's persistent "Recently uploaded" view. - test: upload then list with `?source=upload` (hit) / `?source=youtube` (miss) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,7 @@ async def list_tracks(
|
||||
artist_id: uuid.UUID | None = None,
|
||||
album_id: uuid.UUID | None = None,
|
||||
q: str | None = None,
|
||||
source: str | None = Query(None, max_length=32),
|
||||
sort_by: str = Query("created_at", pattern="^(title|created_at|artist)$"),
|
||||
order: str = Query("desc", pattern="^(asc|desc)$"),
|
||||
limit: int = Query(50, ge=1, le=200),
|
||||
@@ -80,12 +81,15 @@ async def list_tracks(
|
||||
artist_id=artist_id,
|
||||
album_id=album_id,
|
||||
q=q,
|
||||
source=source,
|
||||
sort_by=sort_by,
|
||||
order=order,
|
||||
limit=limit,
|
||||
offset=offset,
|
||||
)
|
||||
total = await track_repo.count(artist_id=artist_id, album_id=album_id, q=q)
|
||||
total = await track_repo.count(
|
||||
artist_id=artist_id, album_id=album_id, q=q, source=source
|
||||
)
|
||||
|
||||
artist_ids = list({t.artist_id for t in tracks})
|
||||
album_ids = list({t.album_id for t in tracks if t.album_id is not None})
|
||||
|
||||
Reference in New Issue
Block a user