Merge branch 'main' into production
Some checks are pending
Deploy Elmeg / deploy (push) Waiting to run

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
This commit is contained in:
fullsizemalt 2025-12-21 03:23:26 -08:00
commit ac755ab7b0

View file

@ -22,7 +22,7 @@ def get_top_shows(limit: int = 10, session: Session = Depends(get_session)):
) )
.join(Rating, Rating.show_id == Show.id) .join(Rating, Rating.show_id == Show.id)
.join(Venue, Show.venue_id == Venue.id) .join(Venue, Show.venue_id == Venue.id)
.where(Rating.entity_type == "show") # Rating FK already filters via join
.group_by(Show.id, Venue.id) .group_by(Show.id, Venue.id)
.having(func.count(Rating.id) >= 1) .having(func.count(Rating.id) >= 1)
.order_by(desc("avg_score"), desc("rating_count")) .order_by(desc("avg_score"), desc("rating_count"))
@ -57,7 +57,7 @@ def get_top_performances(limit: int = 20, session: Session = Depends(get_session
.join(Song, Performance.song_id == Song.id) .join(Song, Performance.song_id == Song.id)
.join(Show, Performance.show_id == Show.id) .join(Show, Performance.show_id == Show.id)
.join(Venue, Show.venue_id == Venue.id) .join(Venue, Show.venue_id == Venue.id)
.where(Rating.entity_type == "performance") # Rating FK already filters via join
.group_by(Performance.id, Song.id, Show.id, Venue.id) .group_by(Performance.id, Song.id, Show.id, Venue.id)
.having(func.count(Rating.id) >= 1) .having(func.count(Rating.id) >= 1)
.order_by(desc("avg_score"), desc("rating_count")) .order_by(desc("avg_score"), desc("rating_count"))
@ -80,19 +80,16 @@ def get_top_performances(limit: int = 20, session: Session = Depends(get_session
@router.get("/venues/top") @router.get("/venues/top")
def get_top_venues(limit: int = 10, session: Session = Depends(get_session)): def get_top_venues(limit: int = 10, session: Session = Depends(get_session)):
"""Get top rated venues based on show ratings there?""" """Get top rated venues based on show ratings there"""
# A venue's rating is often derivative of the shows there, or specific venue ratings. # Aggregate ratings from shows played at each venue
# Let's assume venue rating directly for now if entity_type='venue' exists,
# otherwise we might avg show ratings. Let's start with direct venue ratings.
query = ( query = (
select( select(
Venue, Venue,
func.avg(Rating.score).label("avg_score"), func.avg(Rating.score).label("avg_score"),
func.count(Rating.id).label("rating_count") func.count(Rating.id).label("rating_count")
) )
.join(Rating, Rating.venue_id == Venue.id) .join(Show, Show.venue_id == Venue.id)
.where(Rating.entity_type == "venue") .join(Rating, Rating.show_id == Show.id)
.group_by(Venue.id) .group_by(Venue.id)
.having(func.count(Rating.id) >= 1) .having(func.count(Rating.id) >= 1)
.order_by(desc("avg_score")) .order_by(desc("avg_score"))
@ -101,9 +98,6 @@ def get_top_venues(limit: int = 10, session: Session = Depends(get_session)):
results = session.exec(query).all() results = session.exec(query).all()
# Fallback: if no direct venue ratings, maybe average the shows played there?
# Keeping it simple for now.
return [ return [
{ {
"venue": venue, "venue": venue,