damisproject-0c24n3/endpoints/leaderboard.get.py
2025-03-29 09:55:28 +00:00

20 lines
691 B
Python

from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from typing import List
from core.database import get_db
from models.leaderboard import Leaderboard
from schemas.leaderboard import LeaderboardSchema
from helpers.leaderboard_helpers import get_leaderboard_entries
router = APIRouter()
@router.get("/leaderboard", status_code=200, response_model=List[LeaderboardSchema])
async def get_leaderboard(
limit: int = 10,
skip: int = 0,
game_id: str = None,
db: Session = Depends(get_db)
):
"""Get leaderboard entries"""
leaderboard = get_leaderboard_entries(db, limit=limit, skip=skip, game_id=game_id)
return leaderboard