コード例 #1
0
ファイル: person.py プロジェクト: scrbrd/scoreboard
    def load_leagues(person_id):
        """ Return a Person with Leagues data loaded. """
        (person, leagues) = loader.load_neighbors(
                person_id,
                [API_EDGE_TYPE.IN_LEAGUE],
                [API_NODE_TYPE.LEAGUE])

        person.set_leagues(leagues)

        return person
コード例 #2
0
ファイル: league.py プロジェクト: scrbrd/scoreboard
    def load_opponents(league_id):
        """ Return a League with Opponents loaded from the data layer."""
        (league, opponents) = loader.load_neighbors(
                league_id,
                [API_EDGE_TYPE.HAS_LEAGUE_MEMBER],
                API_CONSTANT.OPPONENT_NODE_TYPES)

        league.set_opponents(opponents)

        return league
コード例 #3
0
ファイル: league.py プロジェクト: scrbrd/scoreboard
    def load_games(league_id):
        """ Return a League with opponents loaded from the data layer."""
        (league, games) = loader.load_neighbors(
                league_id,
                [API_EDGE_TYPE.HAS_SCHEDULED],
                [API_NODE_TYPE.GAME])

        league.set_games(games)

        return league
コード例 #4
0
ファイル: game.py プロジェクト: scrbrd/scoreboard
    def load_important_persons(game_id):
        """ Load the Game's Opponents, Commenters, Creator and attributes into
        a Game.

        Required:
        int game_id     the id of the Game

        Return:
        Game            Game SqNode

        """
        # TODO: commenters should really be loaded in SqNode. This is a mess
        # because load_neighbors returns a single list of neighbors and then we
        # break that list up by type.

        edge_types = []
        edge_types.extend(API_CONSTANT.RESULT_EDGE_TYPES)
        edge_types.append(API_EDGE_TYPE.HAS_COMMENT_FROM)
        edge_types.append(API_EDGE_TYPE.CREATED_BY)

        node_types = []
        node_types.extend(API_CONSTANT.OPPONENT_NODE_TYPES)
        # should include "PERSON_NODE_TYPES"

        (game, important_persons) = loader.load_neighbors(
                game_id,
                edge_types,
                node_types)

        # sort the folks into separate lists of opponents and commenters
        opponent_ids = set(game.results_by_opponent_id.keys())
        comments = game.get_edges().get(
                API_EDGE_TYPE.HAS_COMMENT_FROM,
                {})
        commenter_ids = set(
                [comment.to_node_id for comment in comments.values()])

        opponents = {}
        commenters = {}
        creator = None
        for person in important_persons.values():
            id = person.id
            if id in opponent_ids:
                opponents[id] = person
            if id in commenter_ids:
                commenters[id] = person
            if id == game.creator_id:
                creator = person
        game.set_opponents(opponents)
        game.set_commenters(commenters)
        game.set_creator(creator)

        return game
コード例 #5
0
ファイル: game.py プロジェクト: scrbrd/scoreboard
    def load_opponents(game_id):
        """ Load the Game's Opponents and attributes into a Game.

        Required:
        int game_id     the id of the Game

        Return:
        Game            Game SqNode

        """
        (game, opponents) = loader.load_neighbors(
                game_id,
                API_CONSTANT.RESULT_EDGE_TYPES,
                API_CONSTANT.OPPONENT_NODE_TYPES)

        game.set_opponents(opponents)

        return game