내 지난 얘측 보기 기능 추가, 한국 멕시코 경기 응원가 1곡 추가
This commit is contained in:
1 parent
0e5a63a28b
commit
b4fc96f299
12 files changed
+257
-8
No files matched your search
@@ -7,10 +7,16 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from sqlalchemy.orm import selectinload
|
||||
|
||||
from ..database import get_db
|
||||
from ..domain import compute_phase, crowd_out, is_open_for_voting, is_votable
|
||||
from ..domain import (
|
||||
compute_phase,
|
||||
crowd_out,
|
||||
is_open_for_voting,
|
||||
is_votable,
|
||||
my_prediction_out,
|
||||
)
|
||||
from ..models import AIPrediction, CrowdStats, Match, UserPrediction
|
||||
from ..scoring import outcome_of
|
||||
from ..schemas import SubmitPredictionIn, SubmitPredictionOut
|
||||
from ..schemas import MyPredictionOut, SubmitPredictionIn, SubmitPredictionOut
|
||||
|
||||
router = APIRouter(prefix="/api/predictions", tags=["predictions"])
|
||||
|
||||
@@ -36,6 +42,25 @@ async def _adjust_crowd(
|
||||
)
|
||||
|
||||
|
||||
@router.get("/mine", response_model=list[MyPredictionOut])
|
||||
async def my_predictions(
|
||||
email: str, db: AsyncSession = Depends(get_db)
|
||||
) -> list[MyPredictionOut]:
|
||||
"""이메일 기준 내 지난 예측 목록 (최신 제출순). 로그인 없음 — 이메일이 신원."""
|
||||
e = email.strip().lower()
|
||||
if not e:
|
||||
return []
|
||||
rows = (
|
||||
await db.execute(
|
||||
select(UserPrediction, Match)
|
||||
.join(Match, Match.match_id == UserPrediction.match_id)
|
||||
.where(func.lower(UserPrediction.email) == e)
|
||||
.order_by(UserPrediction.updated_at.desc())
|
||||
)
|
||||
).all()
|
||||
return [my_prediction_out(up, m) for up, m in rows]
|
||||
|
||||
|
||||
@router.post("", response_model=SubmitPredictionOut)
|
||||
async def submit_prediction(
|
||||
body: SubmitPredictionIn, db: AsyncSession = Depends(get_db)
|
||||
|
||||
Reference in new issue
Block a user