Exemple #1
0
def _prepare_result(opponent_ids, type):
    results = {}
    for id in opponent_ids:
        results[id] = {"result": type}

    # convert the results into API_EDGE_TYPEs
    metrics_by_opponent = {}
    for opponent_id, metrics in results.items():
        metric_objects = MetricFactory.produce_metrics(metrics)
        metrics_by_opponent[opponent_id] = metric_objects
    return metrics_by_opponent
Exemple #2
0
    def __init__(self, session, metrics_by_opponent, sport_id):
        """ BaseModel is an abstract superclass.

        Required:
        dict    session                 all the User/Person session data
        dict    metrics_by_opponent     metrics dict keyed on opponent id
        id      sport_id                ID of the Sport for this Game

        """
        super(CreateGameModel, self).__init__(session)

        self._metrics_by_opponent = {}
        self._sport_id = sport_id
        self._league_id = None
        self._message = None

        # convert the results into API_EDGE_TYPEs
        for opponent_id, metrics in metrics_by_opponent.items():
            metric_objects = MetricFactory.produce_metrics(metrics)
            self._metrics_by_opponent[opponent_id] = metric_objects