- Fix TypeError in check_steal_opportunity by properly mocking catcher defense - Correct tag_from_third test calculation to account for all adjustment conditions - Fix pitcher replacement test by setting appropriate allowed runners threshold - Add comprehensive test coverage for AI service business logic - Implement VS Code testing panel configuration with pytest integration - Create pytest.ini for consistent test execution and warning management - Add test isolation guidelines and factory pattern implementation - Establish 102 passing tests with zero failures 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
"""UI Service - handles user interface formatting and display logic.
|
|
|
|
This service contains all business logic for formatting data for display
|
|
that was extracted from models during the migration from Discord app.
|
|
"""
|
|
|
|
import logging
|
|
from .base_service import BaseService
|
|
from ..models.team import Team
|
|
|
|
|
|
class UIService(BaseService):
|
|
"""Service for user interface formatting and display logic."""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.logger = logging.getLogger(f'{__name__}.{self.__class__.__name__}')
|
|
|
|
def format_team_display(self, team: Team) -> dict:
|
|
"""Format team for web display (extracted from Discord embed property).
|
|
|
|
Args:
|
|
team: Team model instance
|
|
|
|
Returns:
|
|
dict: Formatted team display data for web UI
|
|
"""
|
|
self._log_operation(f"Formatting team display for team {team.id}")
|
|
|
|
try:
|
|
# Constants from original Discord app
|
|
SBA_COLOR = 'a6ce39'
|
|
SBA_LOGO = 'https://paper-dynasty.s3.us-east-1.amazonaws.com/static-images/sba-logo.png'
|
|
|
|
display_data = {
|
|
'title': team.lname,
|
|
'color': team.color if team.color else SBA_COLOR,
|
|
'footer_text': f'Paper Dynasty Season {team.season}',
|
|
'footer_icon': SBA_LOGO,
|
|
'thumbnail': team.logo if team.logo else SBA_LOGO,
|
|
'team_id': team.id,
|
|
'abbrev': team.abbrev,
|
|
'season': team.season
|
|
}
|
|
|
|
self.logger.info(f"Successfully formatted team display for {team.abbrev}")
|
|
return display_data
|
|
|
|
except Exception as e:
|
|
self._log_error(f"format_team_display for team {team.id}", e)
|
|
raise |