import logging from typing import List from backend.database.wrapper import player_wrapper from backend.database.wrapper.chart.chart_data import ChartData, ChartDataPoint from backend.database.wrapper.chart.player_chart_metadata import player_group_stats_metadata from backend.database.wrapper.chart.stat_point import StatDataPoint from backend.database.wrapper.stats import player_stat_wrapper logger = logging.getLogger(__name__) wrapper = player_stat_wrapper.PlayerStatWrapper(player_wrapper.PlayerWrapper(limit=10)) class ReplayGroupChartData(ChartData): def __init__(self, title: str, chart_data_points: List[ChartDataPoint], type_: str, subcategory: str): super().__init__(title, chart_data_points) self.type = type_ self.subcategory = subcategory @staticmethod def create_from_ids(ids: List[str]) -> List['ReplayGroupChartData']: stats = wrapper.get_group_stats(ids) player_stats = stats['playerStats'] player_names = [player['name'] for player in player_stats] if 'ensembleStats' in stats: player_stats.append(stats['ensembleStats']) categories = list(player_stats[0]['stats'].keys())
from typing import List from flask import current_app from backend.blueprints.spa_api.service_layers.chart_data import ChartData, ChartDataPoint from backend.database.wrapper import player_wrapper from backend.database.wrapper.stats import player_stat_wrapper from .basic_stats import basic_stats_metadatas wrapper = player_stat_wrapper.PlayerStatWrapper( player_wrapper.PlayerWrapper(limit=10)) class ReplayGroupChartData(ChartData): def __init__(self, title: str, chart_data_points: List[ChartDataPoint], type_: str, subcategory: str): super().__init__(title, chart_data_points) self.type = type_ self.subcategory = subcategory @staticmethod def create_from_ids(ids: List[str]) -> List['ReplayGroupChartData']: session = current_app.config['db']() stats = wrapper.get_group_stats(session, ids) session.close() players = list(stats['playerStats'].keys()) if 'ensembleStats' in stats: players.append('ensembleStats') all_chart_data = [] for basic_stats_metadata in basic_stats_metadatas: