Work on high score endpoints
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import Depends, FastAPI, HTTPException
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -7,6 +7,7 @@ import crud
|
||||
from database import SessionLocal, engine
|
||||
from models import Base
|
||||
from schemas import highscores, users
|
||||
from enums import MinigameEnum
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
@@ -40,9 +41,9 @@ async def create_user(user: users.UserCreate, db: Session = Depends(get_db)):
|
||||
return crud.create_user(db=db, user=user)
|
||||
|
||||
|
||||
@app.get("/highscores", response_model=List[highscores.HighScore])
|
||||
async def read_high_scores(db: Session = Depends(get_db)):
|
||||
high_scores = crud.get_high_scores(db)
|
||||
@app.get("/highscores", response_model=List[users.UserHighScore])
|
||||
async def read_high_scores(db: Session = Depends(get_db), minigame: Optional[MinigameEnum] = None, n_highest: Optional[int] = None):
|
||||
high_scores = crud.get_high_scores(db, minigame, n_highest)
|
||||
return high_scores
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user