def _get_counts(self, session, player_filter=None, replay_ids=None): stats = QueryFilterBuilder().with_stat_query((PlayerGame,)) if player_filter is not None: stats.with_players(player_filter) if replay_ids is not None: stats.with_replay_ids(replay_ids) return stats.build_query(session).filter(PlayerGame.time_in_game > 0).count()
def _create_stats(self, session, player_filter=None, replay_ids=None): average = QueryFilterBuilder().with_stat_query( self.get_player_stat_query()) std_devs = QueryFilterBuilder().with_stat_query( self.get_player_stat_std_query()) if player_filter is not None: average.with_players(player_filter) std_devs.with_players(player_filter) if replay_ids is not None: average.with_replay_ids(replay_ids) std_devs.with_replay_ids(replay_ids) average = average.build_query(session).filter( PlayerGame.time_in_game > 0).first() std_devs = std_devs.build_query(session).filter( PlayerGame.time_in_game > 0).first() average = { n.get_field_name(): round(float(s), 2) for n, s in zip(self.player_stats.stat_list, average) if s is not None } std_devs = { n.get_field_name(): round(float(s), 2) for n, s in zip(self.player_stats.stat_list, std_devs) if s is not None } return {'average': average, 'std_dev': std_devs}
def _create_group_stats_from_query(self, session, query, player_filter=None, replay_ids=None): stats = QueryFilterBuilder().with_stat_query(query) if player_filter is not None: stats.with_players(player_filter) if replay_ids is not None: stats.with_replay_ids(replay_ids) stats = stats.build_query(session).filter(PlayerGame.time_in_game > 0).first() stats = {n.get_query_key(): round(float(s), 2) for n, s in zip(self.player_stats.stat_list, stats) if s is not None} return stats