示例#1
0
def match_history_data(history, account_id):
    """
    this will take a player history and decide which matches need to be downloaded and pass
    them to a multimatch api call this will auto call the function to parse a single players match history
    """
    url = '/multi_match/all/matchids/'
    plus = False
    count = 0
    needed = []
    for m in history:
        if not match.checkfile(m[0]):
            if plus:
                url = url + '+' + str(m[0])
            else:
                url = url + str(m[0])
                plus = True
            count += 1
            needed.append(m)
    if count > 0:
        data = api_call.get_json(url)
        if data is not None:
            match.multimatch(data, needed)
            return get_player_from_matches(history, account_id)
        else:
            return get_player_from_matches(history, account_id)
    else:
        return get_player_from_matches(history, account_id)
示例#2
0
def match_history_data(history, account_id):
    """
    this will take a player history and decide which matches need to be downloaded and pass
    them to a multimatch api call this will auto call the function to parse a single players match history
    """
    url = '/multi_match/all/matchids/'
    plus = False
    count = 0
    needed = []
    for m in history:
        if not match.checkfile(m[0]):
            if plus:
                url = url + '+' + str(m[0])
            else:
                url = url + str(m[0])
                plus = True
            count += 1
            needed.append(m)
    if count > 0:
        data = api_call.get_json(url)
        if data is not None:
            match.multimatch(data, needed)
            return get_player_from_matches(history, account_id)
        else:
            return get_player_from_matches(history, account_id)
    else:
        return get_player_from_matches(history, account_id)
示例#3
0
def verify_matches(data, mode):
    """
    this checks for matches to exist in the database. If they do not exist they are then downloaded.
    """
    findexisting = Matches.objects.filter(match_id__in=data).values('match_id')
    existing = set([int(match['match_id']) for match in findexisting])
    missing = [x for x in data if x not in existing]
    # if any are missing FIND THEM
    if len(missing) != 0:
        strmatches = ''
        for match in missing:
            strmatches += str(match)
            if match != missing[-1]:
                strmatches += '+'
        url = '/multi_match/all/matchids/' + strmatches
        raw = get_json(url)
        if raw != None:
            multimatch(raw, missing, mode)