Skip to content

Commit

Permalink
feat: stats route
Browse files Browse the repository at this point in the history
  • Loading branch information
brownben committed Jan 6, 2025
1 parent f2599c0 commit 940315b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion backend/src/routes/misc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from fastapi.routing import APIRouter

from ..database import Events, Leagues, Results
from ..schemas import HomeDetails
from ..schemas import HomeDetails, StatsOverview

router = APIRouter(
prefix="/misc",
Expand All @@ -17,3 +17,12 @@ async def get_home_details() -> HomeDetails:
events=await Events.count(),
leagues=await Leagues.count(),
)


@router.get("/stats", response_model=StatsOverview)
async def get_summary_stats() -> StatsOverview:
return StatsOverview(
results=await Results.count(),
events=await Events.count(),
leagues=await Leagues.count(),
)
6 changes: 6 additions & 0 deletions backend/src/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ class HomeDetails(BaseModel):
latestResults: list[Event]


class StatsOverview(BaseModel):
leagues: int
events: int
results: int


class CompetitorOverview(Competitor):
results: list[ResultWithEventName]
league: str
Expand Down

0 comments on commit 940315b

Please sign in to comment.