feat: Filter future shows from main list
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run

This commit is contained in:
fullsizemalt 2025-12-24 17:50:08 -08:00
parent f23cec1efc
commit 0f41349817
3 changed files with 13 additions and 1 deletions

View file

@ -23,6 +23,7 @@ def read_shows(
venue_id: int = None, venue_id: int = None,
tour_id: int = None, tour_id: int = None,
year: int = None, year: int = None,
status: str = Query(default=None, regex="^(past|upcoming)$"),
session: Session = Depends(get_session) session: Session = Depends(get_session)
): ):
query = select(Show) query = select(Show)
@ -33,6 +34,13 @@ def read_shows(
if year: if year:
from sqlalchemy import extract from sqlalchemy import extract
query = query.where(extract('year', Show.date) == year) 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() shows = session.exec(query.offset(offset).limit(limit)).all()
return shows return shows

View file

@ -30,7 +30,7 @@ function ShowsContent() {
const [loading, setLoading] = useState(true) const [loading, setLoading] = useState(true)
useEffect(() => { useEffect(() => {
const url = `${getApiUrl()}/shows/?limit=2000${year ? `&year=${year}` : ''}` const url = `${getApiUrl()}/shows/?limit=2000&status=past${year ? `&year=${year}` : ''}`
fetch(url) fetch(url)
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {

View file

@ -21,6 +21,10 @@ export default function SongsPage() {
fetch(`${getApiUrl()}/songs/?limit=1000`) fetch(`${getApiUrl()}/songs/?limit=1000`)
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {
if (!Array.isArray(data)) {
console.error("API Error: Expected array but got:", data)
return
}
// Sort alphabetically // Sort alphabetically
const sorted = data.sort((a: Song, b: Song) => a.title.localeCompare(b.title)) const sorted = data.sort((a: Song, b: Song) => a.title.localeCompare(b.title))
setSongs(sorted) setSongs(sorted)