Exemple #1
0
def processMatch():
    data = request.json
    matchId = data.get('matchId')
    filterdBeatmapList = set([int(x) for x in data.get('filteredBeatmapList')])
    filteredPlayerList = set([int(x) for x in data.get('filteredPlayerList')])
    defaultElo = data.get('defaultElo', 1000)
    logger.info(f'Processing match {matchId}.')
    resp = api.getMatch(matchId)
    parseMatch(resp, filterdBeatmapList, filteredPlayerList, defaultElo)
    match = Match.query.get(matchId)
    calculateEloChange(match)
    return jsonify(matchSchema.dump(match))
Exemple #2
0
def getPlayerEloHistory(playerId):
    try:
        playerId = int(playerId)
    except:
        player = PlayerSummary.query.filter(
            PlayerSummary.name == playerId).one()
        playerId = player.id
    data = db.session.query(Match, EloHistory) \
        .join(EloHistory, EloHistory.match_id == Match.id) \
        .filter(EloHistory.player_id == playerId).all()
    return jsonify([{
        **eloHistorySchema.dump(y),
        **matchSchema.dump(x)
    } for (x, y) in data])
Exemple #3
0
def addAbandoned():
    data = request.json
    match = addAbandonedMatch(int(data['winnerId']), int(data['loserId']),
                              int(data['numMaps']), data['matchName'])
    return jsonify(matchSchema.dump(match))
Exemple #4
0
def getMatches():
    matches = Match.query.all()
    return jsonify([matchSchema.dump(x) for x in matches])
Exemple #5
0
def getPlayerMatches(playerId):
    matches = Player.query.get(playerId).matches
    return jsonify([matchSchema.dump(x) for x in matches])