From 7e63c8775bba0666586b54c0d4f17295b2c31ea5 Mon Sep 17 00:00:00 2001 From: Mawoka Date: Sat, 17 Sep 2022 18:23:30 +0200 Subject: [PATCH] :sparkles: Fixed live-data-endpoint to suit better --- classquiz/routers/quiz.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classquiz/routers/quiz.py b/classquiz/routers/quiz.py index 013b7c9..f94d4ba 100644 --- a/classquiz/routers/quiz.py +++ b/classquiz/routers/quiz.py @@ -7,6 +7,7 @@ import re import uuid from datetime import datetime from random import randint +from typing import Dict import ormar.exceptions @@ -273,12 +274,12 @@ async def get_live_game_data(game_pin: int): @router.get("/live/user_count") -async def get_game_user_count(game_pin: int) -> int: +async def get_game_user_count(game_pin: int) -> dict[str, int]: redis_res = await redis.get(f"game_session:{game_pin}") if redis_res is None: raise HTTPException(status_code=404, detail="Game not found") session = GameSession.parse_raw(redis_res) - return len(session.players) + return {"player_count": len(session.players)} @router.get("/live/players", response_model=GameSession)