当前位置: 首页>>代码示例>>Python>>正文


Python EventDetails.get_by_id_async方法代码示例

本文整理汇总了Python中models.event_details.EventDetails.get_by_id_async方法的典型用法代码示例。如果您正苦于以下问题:Python EventDetails.get_by_id_async方法的具体用法?Python EventDetails.get_by_id_async怎么用?Python EventDetails.get_by_id_async使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.event_details.EventDetails的用法示例。


在下文中一共展示了EventDetails.get_by_id_async方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: generateTeamAtEventStatusAsync

# 需要导入模块: from models.event_details import EventDetails [as 别名]
# 或者: from models.event_details.EventDetails import get_by_id_async [as 别名]
    def generateTeamAtEventStatusAsync(cls, team_key, event):
        """
        Generate [email protected] status items
        :return: a tuple future <long summary string, qual record, qual ranking, playoff status>
        """
        team_number = team_key[3:]
        # We need all the event's playoff matches here to properly account for backup teams
        matches, event_details = yield EventMatchesQuery(event.key.id()).fetch_async(), EventDetails.get_by_id_async(event.key.id())
        qual_match_count = 0
        playoff_match_count = 0
        playoff_matches = []
        for match in matches:
            if match.comp_level in Match.ELIM_LEVELS:
                playoff_match_count += 1
                playoff_matches.append(match)
            else:
                qual_match_count += 1
        matches = MatchHelper.organizeMatches(playoff_matches)

        team_status = cls.generate_team_at_event_status(team_key, event, matches)
        rank_status = team_status.get('rank', None)
        alliance_status = team_status.get('alliance', None)
        playoff_status = team_status.get('playoff', None)

        # Playoff Status
        status, short_playoff_status = cls._get_playoff_status_string(team_key, alliance_status, playoff_status)

        # Still in quals or team did not make it to elims
        if not rank_status or rank_status.get('played', 0) == 0:
            # No matches played yet
            status = "Team {} has not played any matches yet.".format(team_number) if not status else status
            record = '?'
            rank_str = '?'
        else:
            # Compute rank & num_teams
            # Gets record from ranking data to account for surrogate matches
            rank = rank_status.get('rank', '?')
            ranking_points = rank_status.get('first_sort', '?')
            record = rank_status.get('record', '?')
            num_teams = rank_status.get('total', '?')
            rank_str = "Rank {} with {} RP".format(rank, ranking_points)
            alliance_name = alliance_status.get('name', '?') if alliance_status else '?'

            # Compute final long status for nightbot, if one isn't already there
            matches_per_team = qual_match_count // rank_status.get('total', 1)
            if rank_status.get('played', 0) - matches_per_team > 0 and not status:
                if rank is not None:
                    status = "Team {} is currently rank {}/{} with a record of {} and {} ranking points.".format(team_number, rank, num_teams, record, ranking_points)
                else:
                    status = "Team {} currently has a record of {}.".format(team_number, record)
            elif not status:
                if alliance_status is None and playoff_match_count == 0:
                    status = "Team {} ended qualification matches at rank {}/{} with a record of {}.".format(team_number, rank, num_teams, record)
                elif alliance_status is None and playoff_match_count > 0:
                    status = "Team {} ended qualification matches at rank {}/{} with a record of {} and was not picked for playoff matches.".format(team_number, rank, num_teams, record)
                else:
                    status = "Team {} will be competing in the playoff matches on {}.".format(team_number, alliance_name)

        raise ndb.Return(status, record, rank_str, short_playoff_status)
开发者ID:brycematsuda,项目名称:the-blue-alliance,代码行数:61,代码来源:event_team_status_helper.py

示例2: generateTeamAtEventStatusAsync

# 需要导入模块: from models.event_details import EventDetails [as 别名]
# 或者: from models.event_details.EventDetails import get_by_id_async [as 别名]
    def generateTeamAtEventStatusAsync(cls, team_key, event):
        """
        Generate [email protected] status items
        :return: a tuple future <long summary string, qual record, qual ranking, playoff status>
        """
        team_number = team_key[3:]
        matches, event_details = yield TeamEventMatchesQuery(team_key, event.key.id()).fetch_async(), EventDetails.get_by_id_async(event.key.id())
        matches = MatchHelper.organizeMatches(matches)

        # Compute alliances
        alliance_number = cls._get_alliance_number(team_key, event_details)

        # Playoff Status
        status, short_playoff_status = cls._get_playoff_status(team_key, matches, alliance_number)

        # Still in quals or team did not make it to elims
        # Compute qual W-L-T
        wins, losses, ties, unplayed_qual = cls._get_qual_wlt(team_key, matches)
        if wins == 0 and losses == 0 and ties == 0:
            # No matches played yet
            status = "Team {} has not played any matches yet.".format(team_number) if not status else status

        # Compute rank & num_teams
        # Gets record from ranking data to account for surrogate matches
        rank, ranking_points, record, num_teams = cls._get_rank(team_number, event_details)
        rank_str = "Rank {} with {} RP".format(rank, ranking_points)

        # Compute final long status for nightbot, if one isn't already there
        if unplayed_qual > 0 and not status:
            if rank is not None:
                status = "Team {} is currently rank {}/{} with a record of {} and {} ranking points.".format(team_number, rank, num_teams, record, ranking_points)
            else:
                status = "Team {} currently has a record of {}.".format(team_number, record)
        elif not status:
            if alliance_number is None:
                status = "Team {} ended qualification matches at rank {}/{} with a record of {}.".format(team_number, rank, num_teams, record)
            elif alliance_number == 0:
                status = "Team {} ended qualification matches at rank {}/{} with a record of {} and was not picked for playoff matches.".format(team_number, rank, num_teams, record)
            else:
                status = "Team {} will be competing in the playoff matches on alliance #{}.".format(team_number, alliance_number)

        raise ndb.Return(status, record, rank_str, short_playoff_status)
开发者ID:CarterFendley,项目名称:the-blue-alliance,代码行数:44,代码来源:event_team_status_helper.py

示例3: _query_async

# 需要导入模块: from models.event_details import EventDetails [as 别名]
# 或者: from models.event_details.EventDetails import get_by_id_async [as 别名]
 def _query_async(self):
     event_key = self._query_args[0]
     event_details = yield EventDetails.get_by_id_async(event_key)
     raise ndb.Return(event_details)
开发者ID:CarlColglazier,项目名称:the-blue-alliance,代码行数:6,代码来源:event_details_query.py


注:本文中的models.event_details.EventDetails.get_by_id_async方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。