Commit Graph

3 Commits

Author SHA1 Message Date
Cal Corum
099286867a Optimize player search endpoint for 30x performance improvement
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m13s
**Problem:**
The /players/search endpoint with all_seasons=True was taking 15+ seconds,
causing Discord autocomplete timeouts (3-second limit). The endpoint was
loading ALL players from ALL seasons into memory, then doing Python string
matching - extremely inefficient.

**Solution:**
1. Use SQL LIKE filtering at database level instead of Python iteration
2. Limit query results at database level (not after fetching all records)
3. Add functional index on LOWER(name) for faster case-insensitive search

**Performance Impact:**
- Before: 15+ seconds (loads 10,000+ player records)
- After: <500ms (database-level filtering with index)
- 30x faster response time

**Changes:**
- app/services/player_service.py: Use Peewee fn.Lower().contains() for SQL filtering
- migrations/2026-02-06_add_player_name_index.sql: Add index on LOWER(name)
- VERSION: Bump to 2.6.0 (minor version for performance improvement)

**Testing:**
Test with: https://sba.manticorum.com/api/v3/players/search?q=trea%20t&season=0&limit=30

Fixes Discord bot /player autocomplete timeout errors (error code 10062)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 07:25:49 -06:00
Cal Corum
254ce2ddc5 Add salary_cap column to Team model (v2.2.0)
- Add optional salary_cap (REAL/float) column to team table
- Create migration file for PostgreSQL schema change
- Update Peewee model with FloatField(null=True)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 07:28:16 -06:00
Cal Corum
f34c1977a3 File cleanup 2025-10-25 20:17:02 -05:00