fix: Exclude deprecated pitcher_injury field from player responses
Some checks failed
Build Docker Image / build (pull_request) Has been cancelled

The pitcher_injury column is no longer used but was being included in all
player responses after the service layer refactor. This change restores the
previous behavior of filtering it out.

Changes:
- Add EXCLUDED_FIELDS class constant to PlayerService
- Filter excluded fields in _player_to_dict() method
- Update _query_to_player_dicts() to use _player_to_dict() for all conversions
- Applies to both JSON and CSV responses

Version bump: 2.4.1 -> 2.4.2

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Cal Corum 2026-02-04 13:54:30 -06:00
parent 0d9ab7d425
commit d620dfc33d
2 changed files with 14 additions and 17 deletions

View File

@ -1 +1 @@
2.4.1
2.5.1

View File

@ -38,6 +38,9 @@ class PlayerService(BaseService):
cache_patterns = ["players*", "players-search*", "player*", "team-roster*"]
# Deprecated fields to exclude from player responses
EXCLUDED_FIELDS = ['pitcher_injury']
# Class-level repository for dependency injection
_injected_repo: Optional[AbstractPlayerRepository] = None
@ -322,19 +325,10 @@ class PlayerService(BaseService):
if first_item is None:
return []
# If items are already dicts (from mock)
if isinstance(first_item, dict):
players_data = list(query)
if short_output:
return players_data
# Add computed fields if needed
return players_data
# If items are DB models (from real repo)
# Convert all items through _player_to_dict to ensure filtering
players_data = []
for player in query:
player_dict = model_to_dict(player, recurse=not short_output)
player_dict = cls._player_to_dict(player, recurse=not short_output)
players_data.append(player_dict)
return players_data
@ -434,17 +428,20 @@ class PlayerService(BaseService):
@classmethod
def _player_to_dict(cls, player, recurse: bool = True) -> Dict[str, Any]:
"""Convert player to dict."""
# If already a dict, return as-is
"""Convert player to dict, excluding deprecated fields."""
# If already a dict, filter and return
if isinstance(player, dict):
return player
return {k: v for k, v in player.items() if k not in cls.EXCLUDED_FIELDS}
# Try to convert Peewee model
try:
return model_to_dict(player, recurse=recurse)
player_dict = model_to_dict(player, recurse=recurse)
# Filter out excluded fields
return {k: v for k, v in player_dict.items() if k not in cls.EXCLUDED_FIELDS}
except ImportError:
# Fall back to basic dict conversion
return dict(player)
player_dict = dict(player)
return {k: v for k, v in player_dict.items() if k not in cls.EXCLUDED_FIELDS}
@classmethod
def update_player(