From 5b8cfffcf922cc3f3f9033f6b7f6e29edcfa1718 Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Mon, 29 Dec 2025 00:03:56 -0800 Subject: [PATCH] fix: Songs API filtering and default vertical - Added vertical query param to GET /songs for correct filtering - Changed default vertical to Phish (was Goose) to avoid empty data for new users --- backend/routers/songs.py | 19 +++++++++++++++++-- frontend/config/verticals.ts | 2 +- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/backend/routers/songs.py b/backend/routers/songs.py index 5535017..5535da3 100644 --- a/backend/routers/songs.py +++ b/backend/routers/songs.py @@ -19,8 +19,23 @@ def create_song(song: SongCreate, session: Session = Depends(get_session), curre return db_song @router.get("/", response_model=List[SongRead]) -def read_songs(offset: int = 0, limit: int = Query(default=100, le=1000), session: Session = Depends(get_session)): - songs = session.exec(select(Song).offset(offset).limit(limit)).all() +def read_songs( + offset: int = 0, + limit: int = Query(default=100, le=1000), + vertical: str = Query(default=None, description="Filter by vertical slug"), + session: Session = Depends(get_session) +): + query = select(Song) + + if vertical: + from models import Vertical + vertical_entity = session.exec(select(Vertical).where(Vertical.slug == vertical)).first() + if vertical_entity: + query = query.where(Song.vertical_id == vertical_entity.id) + else: + return [] + + songs = session.exec(query.offset(offset).limit(limit)).all() return songs @router.get("/{slug}", response_model=SongReadWithStats) diff --git a/frontend/config/verticals.ts b/frontend/config/verticals.ts index a93d641..a118d73 100644 --- a/frontend/config/verticals.ts +++ b/frontend/config/verticals.ts @@ -1,6 +1,6 @@ export const VERTICALS = [ - { slug: "goose", name: "Goose" }, { slug: "phish", name: "Phish" }, + { slug: "goose", name: "Goose" }, { slug: "grateful-dead", name: "Grateful Dead" }, { slug: "dead-and-company", name: "Dead & Company" }, { slug: "billy-strings", name: "Billy Strings" },