Update CLAUDE.md docs for all-season player search feature
- Document new autocomplete behavior (deduplicated, all-season search) - Add PlayerService.search_players() method signature with all_seasons parameter - Update search logic flow documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
471cb88d1f
commit
2881207ca4
@ -9,20 +9,28 @@ This directory contains Discord slash commands for player information and statis
|
|||||||
- **Description**: Display comprehensive player information and statistics
|
- **Description**: Display comprehensive player information and statistics
|
||||||
- **Parameters**:
|
- **Parameters**:
|
||||||
- `name` (required): Player name to search for
|
- `name` (required): Player name to search for
|
||||||
- `season` (optional): Season for statistics (defaults to current season)
|
- `season` (optional): Season for statistics (defaults to most recent season player appears in)
|
||||||
- **Service Dependencies**:
|
- **Service Dependencies**:
|
||||||
- `player_service.get_players_by_name()`
|
- `player_service.search_players()` - All-season search with deduplication
|
||||||
- `player_service.search_players_fuzzy()`
|
- `player_service.get_players_by_name()` - Season-specific search
|
||||||
|
- `player_service.search_players_fuzzy()` - Fallback fuzzy matching
|
||||||
- `player_service.get_player()`
|
- `player_service.get_player()`
|
||||||
- `stats_service.get_player_stats()`
|
- `stats_service.get_player_stats()`
|
||||||
|
|
||||||
## Key Features
|
## Key Features
|
||||||
|
|
||||||
|
### All-Season Player Search (v2.27.0 - January 2025)
|
||||||
|
- **Autocomplete**: Searches across ALL 13 seasons, returns deduplicated unique player names
|
||||||
|
- **Display Format**: `"Player Name (Position) - Team"` showing most recent season's team
|
||||||
|
- **Deduplication**: Only shows one entry per player name (most recent season takes priority)
|
||||||
|
- **Minimum Characters**: Requires 2+ characters before autocomplete activates
|
||||||
|
|
||||||
### Player Search
|
### Player Search
|
||||||
- **Exact Name Matching**: Primary search method using player name
|
- **All-Season Default**: When no season specified, searches all seasons and uses most recent
|
||||||
- **Fuzzy Search Fallback**: If no exact match, suggests similar player names
|
- **Season-Specific**: When `season` parameter provided, searches only that season
|
||||||
- **Multiple Player Handling**: When multiple players match, attempts exact match or asks user to be more specific
|
- **Fuzzy Search Fallback**: If no exact match, suggests similar player names with season info
|
||||||
- **Suggestion System**: Shows up to 10 suggested players with positions when no exact match found
|
- **Multiple Player Handling**: When multiple players match, shows season info to help distinguish
|
||||||
|
- **Suggestion System**: Shows up to 10 suggested players with positions and seasons
|
||||||
|
|
||||||
### Player Information Display
|
### Player Information Display
|
||||||
- **Basic Info**: Name, position(s), team, season, sWAR, injury status
|
- **Basic Info**: Name, position(s), team, season, sWAR, injury status
|
||||||
@ -53,11 +61,12 @@ This directory contains Discord slash commands for player information and statis
|
|||||||
## Architecture Notes
|
## Architecture Notes
|
||||||
|
|
||||||
### Search Logic Flow
|
### Search Logic Flow
|
||||||
1. Search by exact name in specified season
|
1. **Without season parameter**: Search ALL seasons via `search_players(all_seasons=True)`, use most recent match
|
||||||
2. If no results, try fuzzy search across all players
|
2. **With season parameter**: Search only specified season via `get_players_by_name()`
|
||||||
3. If single result, display player card
|
3. If no results, try fuzzy search across all seasons
|
||||||
4. If multiple results, attempt exact name match
|
4. If single result, display player card
|
||||||
5. If still multiple, show disambiguation list
|
5. If multiple results, attempt exact name match
|
||||||
|
6. If still multiple, show disambiguation list with season info
|
||||||
|
|
||||||
### Performance Optimizations
|
### Performance Optimizations
|
||||||
- `asyncio.gather()` for concurrent API calls
|
- `asyncio.gather()` for concurrent API calls
|
||||||
|
|||||||
@ -286,15 +286,43 @@ for txn in created_transactions:
|
|||||||
print(f"Created transaction {txn.id}: {txn.move_description}")
|
print(f"Created transaction {txn.id}: {txn.move_description}")
|
||||||
```
|
```
|
||||||
|
|
||||||
#### PlayerService Key Methods (October 2025 Update)
|
#### PlayerService Key Methods (January 2025 Update)
|
||||||
```python
|
```python
|
||||||
class PlayerService(BaseService[Player]):
|
class PlayerService(BaseService[Player]):
|
||||||
# Player search and retrieval methods
|
# Player search and retrieval methods
|
||||||
async def get_player(...) -> Optional[Player]
|
async def get_player(...) -> Optional[Player]
|
||||||
async def search_players(...) -> List[Player]
|
async def get_players_by_name(name: str, season: int) -> List[Player]
|
||||||
async def get_players_by_team(...) -> List[Player]
|
async def get_players_by_team(...) -> List[Player]
|
||||||
|
|
||||||
# NEW: Team assignment updates (for /ilmove)
|
# All-season search (v2.27.0 - January 2025)
|
||||||
|
async def search_players(
|
||||||
|
query: str,
|
||||||
|
limit: int = 10,
|
||||||
|
season: Optional[int] = None,
|
||||||
|
all_seasons: bool = False
|
||||||
|
) -> List[Player]:
|
||||||
|
"""
|
||||||
|
Search for players using the dedicated /v3/players/search endpoint.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
query: Search query for player name
|
||||||
|
limit: Maximum number of results to return (1-50)
|
||||||
|
season: Season to search in (defaults to current season if all_seasons=False)
|
||||||
|
all_seasons: If True, search across all seasons (ignores season parameter)
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
List of matching players ordered by most recent season first (when all_seasons=True)
|
||||||
|
"""
|
||||||
|
|
||||||
|
async def search_players_fuzzy(
|
||||||
|
query: str,
|
||||||
|
limit: int = 10,
|
||||||
|
season: Optional[int] = None,
|
||||||
|
all_seasons: bool = False
|
||||||
|
) -> List[Player]:
|
||||||
|
"""Fuzzy search delegating to search_players()."""
|
||||||
|
|
||||||
|
# Team assignment updates (for /ilmove)
|
||||||
async def update_player_team(player_id: int, new_team_id: int) -> Optional[Player]:
|
async def update_player_team(player_id: int, new_team_id: int) -> Optional[Player]:
|
||||||
"""
|
"""
|
||||||
Update a player's team assignment (for real-time IL moves).
|
Update a player's team assignment (for real-time IL moves).
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user