def set_map(db: Database, tournament_id, match_up: MatchUp): key = get_map_key(tournament_id, match_up.left.color, match_up.right.color) db.set(key, match_up.game_map)
try: poll = Poll.validate(body) except typesystem.ValidationError as error: print(error) return Response( str(error), status_code=HTTPStatus.BAD_REQUEST, media_type="application/json", ) # The unique key used to identify each quiz pid = uuid4() poll.creator = request.client.host db.set(pid.hex, json.dumps(dict(poll))) db.hmset(f"{pid.hex}:votes", dict(zip(poll.options, repeat(0)))) return UJSONResponse({"pid": pid.hex}) @app.route("/", methods=["DELETE"]) async def delete(request): pid = UUID(request.query_params["pid"]) db.delete(pid.hex, f"{pid.hex}:votes", f"{pid.hex}:ips") return Response(status_code=HTTPStatus.OK) @app.route("/vote", methods=["POST"]) async def vote(request): """Casts a vote in the quiz"""
def set_sim_log(db: Database, tournament_id, match_up: MatchUp, log: List[str]): key = get_sim_log_key(tournament_id, match_up.left.color, match_up.right.color) db.set(key, json.dumps(log))
def set_importance(db: Database, tournament_id, match_up: MatchUp, importance: List[dict]): key = get_importance_key(tournament_id, match_up.left.color, match_up.right.color) db.set(key, json.dumps(importance))
def set_prediction(db: Database, tournament_id, left_team, right_team, left_wins: float): db.set(get_prediction_key(tournament_id, left_team, right_team), str(left_wins))
def set_current_match(db: Database, left_team, right_team): db.set(CURRENT_MATCH_KEY, f'{left_team} {right_team}')
def set_current_tournament_id(db: Database, tournament_id): db.set(CURRENT_TOURNAMENT_KEY, tournament_id)