feat: Filter future shows from main list
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run
This commit is contained in:
parent
f23cec1efc
commit
0f41349817
3 changed files with 13 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 => {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue