From 8e7be9699187a5a890a438a05034e52e1654dad2 Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Tue, 30 Dec 2025 19:47:55 -0800 Subject: [PATCH] refactor: clarify Top Songs definition - Updated backend to support - Renamed frontend section from 'Top Songs' to 'Most Played Songs' - Ensuring terms are clearly defined throughout the site --- backend/routers/songs.py | 4 ++++ frontend/app/[vertical]/page.tsx | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/routers/songs.py b/backend/routers/songs.py index 5535da3..979be79 100644 --- a/backend/routers/songs.py +++ b/backend/routers/songs.py @@ -23,6 +23,7 @@ def read_songs( offset: int = 0, limit: int = Query(default=100, le=1000), vertical: str = Query(default=None, description="Filter by vertical slug"), + sort: str = Query(default=None, regex="^(times_played)$"), session: Session = Depends(get_session) ): query = select(Song) @@ -34,6 +35,9 @@ def read_songs( query = query.where(Song.vertical_id == vertical_entity.id) else: return [] + + if sort == "times_played": + query = query.outerjoin(Performance).group_by(Song.id).order_by(func.count(Performance.id).desc()) songs = session.exec(query.offset(offset).limit(limit)).all() return songs diff --git a/frontend/app/[vertical]/page.tsx b/frontend/app/[vertical]/page.tsx index ae5fdb4..36a5775 100644 --- a/frontend/app/[vertical]/page.tsx +++ b/frontend/app/[vertical]/page.tsx @@ -139,13 +139,13 @@ export default async function VerticalPage({ params }: Props) { )} - {/* Top Songs */} + {/* Most Played Songs */} {topSongs.length > 0 && (
-

Top Songs

+

Most Played Songs

- All songs + View all songs