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))
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])
def addAbandoned(): data = request.json match = addAbandonedMatch(int(data['winnerId']), int(data['loserId']), int(data['numMaps']), data['matchName']) return jsonify(matchSchema.dump(match))
def getMatches(): matches = Match.query.all() return jsonify([matchSchema.dump(x) for x in matches])
def getPlayerMatches(playerId): matches = Player.query.get(playerId).matches return jsonify([matchSchema.dump(x) for x in matches])