Beispiel #1
0
 def get_batter_results(self, matrix, calculator, batter):
     batter_events = filter(lambda x: x.batter == batter.mlb_id, event_data)
     batter_events = split_events_by_game(batter_events)
     batter_results = list()
     for event_list in batter_events:
         total = 0
         for event in event_list:
             total += matrix.get_cell(event.batter, event.pitcher)
         game_results = GameResult()
         game_results.calculator = calculator.id
         game_results.mlb_id = batter.mlb_id
         game_results.player_type = constants.BATTER
         game_results.actions = len(event_list)
         game_results.score = total
         game_results.game = event_list[0].game_id
         batter_results.append(game_results)
     return batter_results
Beispiel #2
0
 def get_batter_results(self, batter):
     batter_events = session.query(Event).filter(Event.batter == batter.mlb_id).order_by(Event.game_id).all()
     batter_events = split_events_by_game(batter_events)
     batter_results = list()
     for event_list in batter_events:
         total = 0
         for event in event_list:
             total += self.scorer.score_batter(event)
         game_results = GameResult()
         game_results.calculator = self.calculator.id
         game_results.mlb_id = batter.mlb_id
         game_results.player_type = constants.BATTER
         game_results.actions = len(event_list)
         game_results.score = total
         game_results.game = event_list[0].game_id  # guaranteed to have one element
         batter_results.append(game_results)
     return batter_results