def process_region(region):
    elastic = elasticsearch.Elasticsearch()
    baseriotapi.set_region(region)
    d = str(baseriotapi.get_challenger("RANKED_SOLO_5x5"))
    j = json.loads(d)
    wins, mostWins, lastWins, losses, mostLosses, lastLosses, count = 0, 0, 0, 0, 0, 0, 0
    userMostWins, userMostLosses = "", ""


    for entry in j['entries']:
        wins += int(entry['wins'])
        if int(entry['wins']) > mostWins:
            mostWins = int(entry['wins'])
            userMostWins = entry['playerOrTeamName']
        losses += int(entry['losses'])
        if int(entry['losses']) > mostLosses:
            mostLosses = int(entry['losses'])
            userMostLosses = entry['playerOrTeamName']
        count += 1

    try:
        avgWins = round(wins / count)
        lastWins = int(config.get(region, 'wins'))
        avgLosses = round(losses / count)
        lastLosses = int(config.get(region, 'losses'))
        config.set(region, 'wins', wins)
        config.set(region, 'losses', losses)
        config.set(region, 'avg_wins', avgWins)
        config.set(region, 'avg_losses', avgLosses)
        newWins = wins - lastWins
        newLosses = losses - lastLosses
        timestamp = datetime.utcnow()

        elastic.index(index='lol_challenger_solo_weekly', doc_type='weekly_played', body={"region": region, "wins": newWins,
                                                                                          "most_wins": mostWins, "user_most_wins": userMostWins,
                                                                                          "avg_wins": avgWins, "losses": newLosses,
                                                                                          "most_losses": mostLosses,
                                                                                          "user_most_losses": userMostLosses,
                                                                                          "avg_losses": avgLosses,
                                                                                          "timestamp": timestamp})

    except:
        traceback.print_exc()
Beispiel #2
0
def test_challenger():
    int_test_handler.test_result(baseriotapi.get_challenger("RANKED_SOLO_5x5"))
Beispiel #3
0
def test_challenger():
    int_test_handler.test_result(baseriotapi.get_challenger("RANKED_SOLO_5x5"))