From 052918184764b5b332a4c3eebac54f8796740235 Mon Sep 17 00:00:00 2001 From: Mawoka Date: Wed, 5 Oct 2022 13:54:04 +0200 Subject: [PATCH] :goal_net: Catching error if nobody has answered --- classquiz/routers/live.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/classquiz/routers/live.py b/classquiz/routers/live.py index 65e683f..3854478 100644 --- a/classquiz/routers/live.py +++ b/classquiz/routers/live.py @@ -248,7 +248,10 @@ async def voting_results(game_pin: str, api_key: str, as_array: bool = False): game = PlayGame.parse_raw(redis_res) if game.questions[game.current_question].type != QuizQuestionType.VOTING: return - answer_list = _AnswerDataList.parse_raw(await redis.get(f"game_session:{game_pin}:{game.current_question}")) + answer_data = await redis.get(f"game_session:{game_pin}:{game.current_question}") + if answer_data is None: + return + answer_list = _AnswerDataList.parse_raw(answer_data) answer_dict = {} for answer in game.questions[game.current_question].answers: answer_dict[answer.answer] = 0