From 0f41349817aca9f9158ec42503c6b27298536cfa Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Wed, 24 Dec 2025 17:50:08 -0800 Subject: [PATCH] feat: Filter future shows from main list --- backend/routers/shows.py | 8 ++++++++ frontend/app/shows/page.tsx | 2 +- frontend/app/songs/page.tsx | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/routers/shows.py b/backend/routers/shows.py index 9f07a42..c389b26 100644 --- a/backend/routers/shows.py +++ b/backend/routers/shows.py @@ -23,6 +23,7 @@ def read_shows( venue_id: int = None, tour_id: int = None, year: int = None, + status: str = Query(default=None, regex="^(past|upcoming)$"), session: Session = Depends(get_session) ): query = select(Show) @@ -33,6 +34,13 @@ def read_shows( if year: from sqlalchemy import extract query = query.where(extract('year', Show.date) == year) + + if status: + from datetime import datetime + if status == "past": + query = query.where(Show.date <= datetime.now()) + elif status == "upcoming": + query = query.where(Show.date > datetime.now()) shows = session.exec(query.offset(offset).limit(limit)).all() return shows diff --git a/frontend/app/shows/page.tsx b/frontend/app/shows/page.tsx index 52e2e41..66ad59e 100644 --- a/frontend/app/shows/page.tsx +++ b/frontend/app/shows/page.tsx @@ -30,7 +30,7 @@ function ShowsContent() { const [loading, setLoading] = useState(true) useEffect(() => { - const url = `${getApiUrl()}/shows/?limit=2000${year ? `&year=${year}` : ''}` + const url = `${getApiUrl()}/shows/?limit=2000&status=past${year ? `&year=${year}` : ''}` fetch(url) .then(res => res.json()) .then(data => { diff --git a/frontend/app/songs/page.tsx b/frontend/app/songs/page.tsx index 7b68bad..53df976 100644 --- a/frontend/app/songs/page.tsx +++ b/frontend/app/songs/page.tsx @@ -21,6 +21,10 @@ export default function SongsPage() { fetch(`${getApiUrl()}/songs/?limit=1000`) .then(res => res.json()) .then(data => { + if (!Array.isArray(data)) { + console.error("API Error: Expected array but got:", data) + return + } // Sort alphabetically const sorted = data.sort((a: Song, b: Song) => a.title.localeCompare(b.title)) setSongs(sorted)