def hello(): if 'text' not in request.form or request.form['text'] == "": logging.debug(f'Received invalid command') return api.error_response('Invalid command') command, _, _ = request.form['text'].strip().partition(' ') if command == 'new': new_kickup = st.new_kickup() logging.info(f'Created new kickup with identifier {new_kickup.num}') return api.respond(new_kickup) elif command == 'elo': leaderboard = elo.leaderboard(persistence.matches_sorted()) return api.elo_leaderboard_resp(leaderboard) elif command.startswith('teams'): boards = inject.boards teamboard = None arguments = parse_arguments(command) if len(arguments) == 0: teamboard = boards.elo_by_team() elif isinstance(arguments[0], int): teamboard = boards.elo_by_teams_using_last_matches(arguments[0]) elif isinstance(arguments[0], timedelta): teamboard = boards.elo_by_teams_using_matches_since(datetime.today( ).replace(hour=0, minute=0, second=0, microsecond=0) - arguments[0]) else: return api.error_response(f'Invalid parameters: "{command}"') return jsonify(inject.slack.from_teamboard(teamboard)) else: return api.error_response(f'Invalid command: "{command}"')
def possible_scores(self): match_win_a = persistence.Match( self.pairing.goal_a._id, self.pairing.strike_a._id, self.pairing.goal_b._id, self.pairing.strike_b._id, 6, 0, datetime.datetime.now(), ) match_win_b = copy.deepcopy(match_win_a) match_win_b.score_a = 0 match_win_b.score_b = 6 self.max_win_a = elo.leaderboard( persistence.matches_sorted()).eval_match(match_win_a).last_delta self.max_win_b = elo.leaderboard( persistence.matches_sorted()).eval_match(match_win_b).last_delta
def possible_scores(self): match_win_A = persistence.Match( self.pairing.goal_A._id, self.pairing.strike_A._id, self.pairing.goal_B._id, self.pairing.strike_B._id, 6, 0, datetime.datetime.now(), ) match_win_B = copy.deepcopy(match_win_A) match_win_B.score_A = 0 match_win_B.score_B = 6 self.max_win_A = elo.leaderboard( persistence.matches_sorted()).eval_match(match_win_A).last_delta self.max_win_B = elo.leaderboard( persistence.matches_sorted()).eval_match(match_win_B).last_delta
def hello(): if not 'text' in request.form or request.form['text'] == "": logging.debug(f'Received invalid command') return api.error_response('Invalid command') command, _, _ = request.form['text'].strip().partition(' ') if command == 'new': new_kickup = st.new_kickup() logging.info(f'Created new kickup with identifier { new_kickup.num }') return api.respond(new_kickup) elif command == 'elo': leaderboard = elo.leaderboard(persistence.matches_sorted()) return api.elo_leaderboard_resp(leaderboard) else: return api.error_response(f'Invalid command: "{ command }"')
def hello(): if not 'text' in request.form or request.form['text'] == "": logging.debug(f'Received invalid command') return api.error_response('Invalid command') command, _, args = request.form['text'].strip().partition(' ') if command == 'new': g.context_player = get_player_from_request() new_kickup = st.new_kickup() new_kickup.add_player(g.context_player()) logging.info(f'Created new kickup with identifier { new_kickup.num }') return api.respond(new_kickup) elif command == 'elo': leaderboard = elo.leaderboard() return api.elo_leaderboard_resp(leaderboard) else: return api.error_response(f'Invalid command: "{ command }"')
def hello(): if not 'text' in request.form or request.form['text'] == "": return api.error_response('Invalid command') command, _, args = request.form['text'].strip().partition(' ') if command == 'new': new_kickup = st.new_kickup() logging.info(f'Created new kickup with identifier { new_kickup.num }') return api.respond(new_kickup) elif command == 'leaderboard': leaderboard = pack.packeroo_leaderboard() return api.leaderboard_resp(leaderboard) elif command == 'elo': leaderboard = elo.leaderboard() return api.elo_leaderboard_resp(leaderboard) elif command == 'elogd100': leaderboard = elo.leaderboard_gd100() return api.elo_leaderboard_resp(leaderboard) elif command == 'elogd400': leaderboard = elo.leaderboard_gd400() return api.elo_leaderboard_resp(leaderboard) else: return api.error_response(f'Invalid command: "{ command }"')