Beispiel #1
0
def _print_tournament_data(match_date, tournament_id):
    content = ''

    whole_match_headers = get_match_headers()
    attainable_match_headers = whole_match_headers[ whole_match_headers['date'] <= eve_datetime(match_date) ]

    first_year = match_date.year if match_date.month >= 6 else match_date.year - 1
    tournament_season_match_headers = get_tournament_season_substatistic(attainable_match_headers, tournament_id, first_year)
    sorted_tournament_season_match_headers = tournament_season_match_headers.sort_values('date', ascending=True)

    home_teams = frozenset(tournament_season_match_headers['home'].values)
    away_teams = frozenset(tournament_season_match_headers['away'].values)
    teams = home_teams | away_teams

    data = { home: { away: None for away in teams } for home in teams }
    for (match_uuid, match_header) in sorted_tournament_season_match_headers.iterrows():
        events_counts = count_events_of_teams_by_match_uuid(is_corner, match_uuid)
        if events_counts is None:
            continue
        first_period_events_counts = count_events_of_teams_by_match_uuid(conjunct(is_corner, is_first_period), match_uuid)
        second_period_events_counts = count_events_of_teams_by_match_uuid(conjunct(is_corner, is_second_period), match_uuid)

        data[ match_header['home'] ][ match_header['away'] ] = (events_counts[0], events_counts[1], first_period_events_counts[0], first_period_events_counts[1], second_period_events_counts[0], second_period_events_counts[1])

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

    content += '<tr>'
    content += '<th></th>'
    for team in sorted(teams):
        content += '<th>' + team + '</th>'
    content += '</tr>'

    for home in sorted(teams):
        content += '<tr>'
        content += '<th>' + home + '</th>'
        for away in sorted(teams):
            match_data = data[home][away]
            if match_data is not None:
                content += '<td>%u : %u (%u : %u / %u : %u)</td>' % match_data
            else:
                content += '<td></td>'
        content += '</tr>'

    content += '</table>'

    return content
Beispiel #2
0
def _print_teams_statistic(match_header, is_home):
    content = ''

    team = match_header['home'] if is_home else match_header['away']

    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]

    content += '<table>'
    content += '<thead>'
    content += '<tr>'
    content += '<th>Дата</th>'
    content += '<th>Хозяева</th>'
    content += '<th>Гости</th>'
    content += '<th>Угловые (матч)</th>'
    content += '<th>Угловые (1-й тайм)</th>'
    content += '<th>Угловые (2-й тайм)</th>'
    content += '</tr>'
    content += '</thead>'
    content += '<tbody>'

    for (match_uuid, match_header) in last_match_headers.iterrows():
        corners_counts = count_events_of_teams_by_match_uuid(is_corner, match_uuid)
        if corners_counts is None:
            continue
        first_period_corners_counts = count_events_of_teams_by_match_uuid(conjunct(is_corner, is_first_period), match_uuid)
        second_period_corners_counts = count_events_of_teams_by_match_uuid(conjunct(is_corner, is_second_period), match_uuid)

        if (is_home and match_header['home'] == team) or (not is_home and match_header['away'] == team):
            content += '<tr class="active">'
        else:
            content += '<tr>'
        content += '<td>' + match_header['date'].strftime('%Y-%m-%d') + '</td>'
        content += '<td>' + match_header['home'] + '</td>'
        content += '<td>' + match_header['away'] + '</td>'
        content += '<td>%u : %u</td>' % corners_counts
        content += '<td>%u : %u</td>' % first_period_corners_counts
        content += '<td>%u : %u</td>' % second_period_corners_counts
        content += '</tr>'

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

    return content
    def _get_match_statistic_data(self, match_header):
        (red_cards_second_period_home_count, red_cards_second_period_away_count
         ) = count_events_of_teams_by_match_uuid(
             conjunct(is_red_card, is_second_period), match_header['uuid'])

        match_statistic_data = {
            'events_home_count': red_cards_second_period_home_count,
            'events_away_count': red_cards_second_period_away_count
        }

        return match_statistic_data
    def _get_match_statistic_data(self, match_header):
        (crosses_first_period_home_count, crosses_first_period_away_count
         ) = count_events_of_teams_by_match_uuid(
             conjunct(is_cross, is_first_period), match_header['uuid'])

        match_statistic_data = {
            'events_home_count': crosses_first_period_home_count,
            'events_away_count': crosses_first_period_away_count
        }

        return match_statistic_data
    def _get_match_statistic_data(self, match_header):
        (corners_first_period_home_count, corners_first_period_away_count) = count_events_of_teams_by_match_uuid(conjunct(is_corner, is_first_period, is_goals_score_2), match_header['uuid'])

        match_statistic_data = {
            'events_home_count': corners_first_period_home_count,
            'events_away_count': corners_first_period_away_count
        }

        return match_statistic_data
Beispiel #6
0
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(
            conjunct(is_cross, is_second_period), match_header['uuid'])

        return match_statistic_data