응원가를 MLB 로 확장 (MLS 제외)
- MLB 라인업: Stats API schedule→gamePk→boxscore battingOrder (양팀 9명 = 발표) - 작사 프롬프트 리그 분기 (MLB 는 한국 팬 표기 지시) - /api/songs/today league 미지정 시 전 리그 반환, 프론트는 전 리그 조회 - 상세 페이지 응원가 버튼 KBO+MLB 노출 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0fc7598d88
commit
dbd08e62c7
5 files changed
+102
-28
No files matched your search
@@ -30,18 +30,16 @@ def _song_out(s: Song) -> dict:
|
||||
|
||||
|
||||
@router.get("/today")
|
||||
async def today_songs(league: str = "kbo", db: AsyncSession = Depends(get_db)) -> list[dict]:
|
||||
async def today_songs(league: str = "", db: AsyncSession = Depends(get_db)) -> list[dict]:
|
||||
"""오늘의 응원가 목록 — league 미지정 시 전 리그(kbo+mlb)."""
|
||||
today = datetime.now(KST).date()
|
||||
# 업그레이드(라인업 반영 재생성) 중인 곡도 이전 트랙을 계속 서빙 — 재생 공백 없음
|
||||
conds = [Song.date_kst == today, Song.status.in_(("complete", "generating"))]
|
||||
if league:
|
||||
conds.append(Song.league == league)
|
||||
rows = (
|
||||
await db.execute(
|
||||
select(Song)
|
||||
.where(
|
||||
Song.league == league,
|
||||
Song.date_kst == today,
|
||||
Song.status.in_(("complete", "generating")),
|
||||
)
|
||||
.order_by(Song.match_id, Song.team_code)
|
||||
select(Song).where(*conds).order_by(Song.match_id, Song.team_code)
|
||||
)
|
||||
).scalars().all()
|
||||
return [_song_out(s) for s in rows if s.tracks]
|
||||
|
||||
Reference in new issue
Block a user