fix: Fix import shadowing in routers
This commit is contained in:
parent
a12f7fa8b0
commit
66b5039337
2 changed files with 6 additions and 16 deletions
|
|
@ -1,8 +1,8 @@
|
|||
from typing import List
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlmodel import Session, select
|
||||
from sqlmodel import Session, select, func
|
||||
from database import get_session
|
||||
from models import Performance, PerformanceNickname, Tag, EntityTag
|
||||
from models import Performance, PerformanceNickname, Tag, EntityTag, Show
|
||||
from schemas import PerformanceDetailRead, PerformanceNicknameCreate, PerformanceNicknameRead
|
||||
from auth import get_current_user
|
||||
|
||||
|
|
@ -26,9 +26,6 @@ def read_performance(performance_id_or_slug: str, session: Session = Depends(get
|
|||
performance_id = performance.id # Use actual ID for lookups
|
||||
|
||||
# --- Calculate Stats & Navigation ---
|
||||
from sqlmodel import select, func, desc
|
||||
from models import Show
|
||||
|
||||
# Get all performances of this song, ordered by date
|
||||
# We need to join Show to order by date
|
||||
all_perfs = session.exec(
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
from typing import List
|
||||
from datetime import datetime
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlmodel import Session, select
|
||||
from sqlmodel import Session, select, func
|
||||
from database import get_session
|
||||
from models import Song, User, Tag, EntityTag
|
||||
from schemas import SongCreate, SongRead, SongReadWithStats, SongUpdate, TagRead
|
||||
from models import Song, User, Tag, EntityTag, Show, Performance, Rating
|
||||
from schemas import SongCreate, SongRead, SongReadWithStats, SongUpdate, TagRead, PerformanceReadWithShow
|
||||
from auth import get_current_user
|
||||
from services.stats import get_song_stats
|
||||
|
||||
router = APIRouter(prefix="/songs", tags=["songs"])
|
||||
|
||||
|
|
@ -22,8 +23,6 @@ def read_songs(offset: int = 0, limit: int = Query(default=100, le=100), session
|
|||
songs = session.exec(select(Song).offset(offset).limit(limit)).all()
|
||||
return songs
|
||||
|
||||
from services.stats import get_song_stats
|
||||
|
||||
@router.get("/{song_id_or_slug}", response_model=SongReadWithStats)
|
||||
def read_song(song_id_or_slug: str, session: Session = Depends(get_session)):
|
||||
# Try to parse as int (ID), otherwise treat as slug
|
||||
|
|
@ -49,12 +48,6 @@ def read_song(song_id_or_slug: str, session: Session = Depends(get_session)):
|
|||
).all()
|
||||
|
||||
# Fetch performances
|
||||
# We join Show to ensure we can order by date
|
||||
from models import Show, Performance, Rating
|
||||
from sqlmodel import func
|
||||
# We need PerformanceReadWithShow from schemas
|
||||
from schemas import PerformanceReadWithShow
|
||||
|
||||
perfs = session.exec(
|
||||
select(Performance)
|
||||
.join(Show)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue