def _get_match_statistic_data(self, match_header):
        match_statistic_data = count_events_of_players_by_match_uuid(
            conjunct(is_cross, is_second_period), match_header['uuid'])

        return match_statistic_data
示例#2
0
文件: main.py 项目: kuraga/betrobot
def _print_players_statistic(match_header, is_home):
    team = match_header['home'] if is_home else match_header['away']
    k = 'homePlayers' if is_home else 'awayPlayers'

    additional_info_collection = db['additional_info']
    additional_info = additional_info_collection.find_one({ 'match_uuid': match_header['uuid'] })
    if k not in additional_info:
        return ''

    player_names = [ player['playerName'] for player in additional_info[k] if player['isFirstEleven'] ]
    data = { player_name: {} for player_name in player_names }
    first_period_data = { player_name: {} for player_name in player_names }
    second_period_data = { player_name: {} for player_name in player_names }

    whole_match_headers = get_match_headers()
    attainable_match_headers = whole_match_headers[ whole_match_headers['date'] <= eve_datetime(match_header['date']) ]
    attainable_team_match_headers = attainable_match_headers[ (attainable_match_headers['home'] == team) | (attainable_match_headers['away'] == team) ]
    last_match_headers = attainable_team_match_headers[:10]

    for (match_uuid_, match_header_) in last_match_headers.iterrows():
        player_counts = count_events_of_players_by_match_uuid(is_corner, match_uuid_)
        if player_counts is None:
            continue
        first_period_player_counts = count_events_of_players_by_match_uuid(conjunct(is_corner, is_first_period), match_uuid_)
        second_period_player_counts = count_events_of_players_by_match_uuid(conjunct(is_corner, is_second_period), match_uuid_)

        for player_name in player_counts:
            if player_name in data:
                data[player_name][match_uuid_] = player_counts[player_name]
                first_period_data[player_name][match_uuid_] = first_period_player_counts[player_name]
                second_period_data[player_name][match_uuid_] = second_period_player_counts[player_name]

    content = ''

    content += '<table>'
    content += '<tbody>'

    content += '<tr>'
    content += '<th></th>'
    for (match_uuid, match_header) in last_match_headers.iterrows():
        content += '<th>' + get_match_title(match_header) + '</th>'
    content += '</tr>'

    for player_name in player_names:
        content += '<tr>'
        content += '<th>' + player_name + '</th>'
        for (match_uuid, match_header) in last_match_headers.iterrows():
            if match_uuid in data[player_name]:
                content += '<td>%u (%u / %u)</td>' % (data[player_name][match_uuid], first_period_data[player_name][match_uuid], second_period_data[player_name][match_uuid])
            else:
                content += '<td></td>'
        content += '</tr>'

    content += '<tr><td>(%u игроков)</td></tr>' % (len(player_names),)

    content += '</tbody>'
    content += '</table>'

    content += _print_unmatched_player_names(match_header, is_home)

    return content
    def _get_match_statistic_data(self, match_header):
        match_statistic_data = count_events_of_players_by_match_uuid(
            is_cross, match_header['uuid'])

        return match_statistic_data