import json from web.services.web_service import WebService class TeamContextService: """Single source of truth for the private team's active roster.""" @staticmethod def get_active_lineup(): lineup = WebService.get_active_lineup() return dict(lineup) if lineup else None @staticmethod def get_active_roster_ids(): lineup = TeamContextService.get_active_lineup() if not lineup: return [] try: raw_ids = json.loads(lineup.get('player_ids_json') or '[]') except (TypeError, json.JSONDecodeError): return [] if not isinstance(raw_ids, list): return [] seen = set() roster_ids = [] for raw_id in raw_ids: steam_id = str(raw_id).strip() if steam_id and steam_id not in seen: seen.add(steam_id) roster_ids.append(steam_id) return roster_ids