Commit Graph

144 Commits

Author SHA1 Message Date
Cal Corum
e75c1fbc7d CLAUDE: Complete PostgreSQL migration for custom commands
- Update CLAUDE.md to reflect PostgreSQL-only architecture
- Add table_name Meta class to CustomCommand models for PostgreSQL
- Remove SQLite-specific LIKE queries, use PostgreSQL ILIKE
- Refactor custom command creator info handling
- Add helper functions for database operations
- Fix creator data serialization in execute endpoint

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 16:07:18 -05:00
Cal Corum
4db6982bc5 CLAUDE: Add Redis cache invalidation to player mutation endpoints
- Add cache invalidation to PUT, PATCH, POST, and DELETE endpoints
- Invalidate all player list, search, and detail caches on data changes
- Increase cache TTLs now that invalidation ensures accuracy:
  - GET /players: 10min → 30min
  - GET /players/search: 5min → 15min
  - GET /players/{player_id}: 10min → 30min

This ensures users see updated player data immediately after changes
while benefiting from longer cache lifetimes for read operations.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 16:02:00 -05:00
Cal Corum
a9e749640d Added /search endpoint to /players 2025-10-17 16:37:01 -05:00
Cal Corum
d32f9a8239 Added HelpCommands 2025-10-17 16:36:40 -05:00
Cal Corum
a540a3e7f3 Add Redis Caching 2025-08-27 22:49:37 -05:00
Cal Corum
abf4435931 CLAUDE: Fix cache_result decorator to handle Response objects properly
- Skip caching for FastAPI Response objects (CSV downloads, etc.)
- Response objects can't be JSON-serialized/deserialized without corruption
- Regular JSON responses continue to be cached normally
- Fixes issue where CSV endpoints returned Response object string representation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-27 22:48:30 -05:00
Cal Corum
2c3835c8ac Added SeasonPitchingStats 2025-08-26 00:17:57 -05:00
Cal Corum
8c492273dc Postgres Query Updates
Fixing query errors caused by Postgres vs SQLite
2025-08-25 07:19:13 -05:00
Cal Corum
54a1a407d0 CLAUDE: Season batting stats table and selective update system
Major database enhancement implementing fast-querying season batting stats:

Database Schema:
- Created seasonbattingstats table with composite primary key (player_id, season)
- All batting stats (counting + calculated): pa, ab, avg, obp, slg, ops, woba, etc.
- Proper foreign key constraints and performance indexes
- Production-ready SQL creation script included

Selective Update System:
- update_season_batting_stats() function with PostgreSQL upsert logic
- Triggers on game PATCH operations to update affected player stats
- Recalculates complete season stats from stratplay data
- Efficient updates of only players who participated in modified games

API Enhancements:
- Enhanced SeasonBattingStats.get_top_hitters() with full filtering support
- New /api/v3/views/season-stats/batting/refresh endpoint for season rebuilds
- Updated views endpoint to use centralized get_top_hitters() method
- Support for team, player, min PA, and pagination filtering

Infrastructure:
- Production database sync Docker service with SSH automation
- Comprehensive error handling and logging throughout
- Fixed Peewee model to match actual table structure (no auto-id)
- Updated CLAUDE.md with dev server info and sync commands

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-23 22:18:27 -05:00
Cal Corum
c05d00d60e DB Error Handling
Added error handling wrapper and fixed SQLite -> Postgres issues
2025-08-20 19:33:40 -05:00
Cal Corum
91ae5a972f Local migration fully functional 2025-08-20 09:52:46 -05:00
Cal Corum
f49adf3c64 CLAUDE: Phase 2 PostgreSQL migration BREAKTHROUGH complete
🚀 MASSIVE SUCCESS: 77% of tables now migrating successfully!

Major Achievements:
- 23/30 tables successfully migrating (up from 7/30)
- ~373,000 records migrated (up from ~5,432)
- ALL schema compatibility issues resolved
- ALL NULL constraint issues resolved

Issues resolved in Phase 2:
- CONSTRAINT-CURRENT-BSTATCOUNT-001: Made nullable
- CONSTRAINT-CURRENT-PSTATCOUNT-001: Made nullable
- CONSTRAINT-TEAM-AUTO_DRAFT-001: Made nullable
- CONSTRAINT-CURRENT-BET_WEEK-001: Made nullable (bonus discovery)
- CONSTRAINT-TEAM-GMID-001: Made nullable (bonus discovery)

Major tables now working:
 current (11 records)
 team (546 records)
 player (12,232 records)
 battingstat (105,413 records)
 pitchingstat (35,281 records)
 stratgame (2,468 records)
 stratplay (192,790 records)

Remaining issues (7 tables): Foreign key dependencies and missing tables

Next: Phase 3 - Foreign key resolution for final 23% of tables

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 18:31:18 -05:00
Cal Corum
79a559088a CLAUDE: Phase 1 PostgreSQL migration fixes complete
- Fixed 4 critical schema issues blocking migration
- Resolved integer overflow by converting Discord IDs to strings
- Fixed VARCHAR length limits for Google Photos URLs
- Made injury_count field nullable for NULL values
- Successfully migrating 7/30 tables (5,432+ records)

Issues resolved:
- CONSTRAINT-CURRENT-INJURY_COUNT-001: Made nullable
- DATA_QUALITY-PLAYER-NAME-001: Increased VARCHAR limits to 1000
- MIGRATION_LOGIC-TEAM-INTEGER-001: Discord IDs now strings
- MIGRATION_LOGIC-DRAFTDATA-INTEGER-001: Channel IDs now strings

New issues discovered for Phase 2:
- CONSTRAINT-CURRENT-BSTATCOUNT-001: NULL stats count
- CONSTRAINT-TEAM-AUTO_DRAFT-001: NULL auto draft flag

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-18 18:09:45 -05:00
Cal Corum
27369a92fb Added custom_commands endpoint 2025-08-18 16:27:39 -05:00
Cal Corum
57c943e340 CLAUDE: Add custom commands system with migration from legacy database
- Add CustomCommandCreator and CustomCommand models to db_engine.py
- Add comprehensive custom commands API router with full CRUD operations
- Include migration script for transferring 140 commands from sba_is_fun.db
- Add FastAPI integration for /api/v3/custom_commands endpoints
- Implement usage tracking, search, autocomplete, and statistics features
- Add grace period handling for unused commands to prevent deletion
- Include comprehensive documentation for migration process

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-17 16:31:39 -05:00
Cal Corum
e85cac61df Fix dupe check on sbaplayers 2025-06-11 00:33:09 -05:00
Cal Corum
1d652ee5fa Added SbaPlayer table 2025-05-30 21:41:40 -05:00
Cal Corum
cd1321553e Logging updates 2024-12-16 09:03:23 -06:00
Peter
df73e49406 Improve alias naming 2024-11-16 09:12:30 -06:00
Peter
c5b546d0ed Align home_score with runs_scored for pythag record 2024-11-15 16:52:29 -06:00
Cal Corum
ffb70f1633 Update stratplay.py
Fixed catcher stats in /fielding
2024-10-31 09:48:47 -05:00
Cal Corum
4e21e42b6d Update stratplay.py
Fixed group_by not properly grouping SB/CS and decisions
2024-10-30 21:38:19 -05:00
Cal Corum
4380c26319 Add Swagger support 2024-07-14 13:23:37 -05:00
Cal Corum
a935688518 Update players.py
Migrate patch players to put and add new patch players endpoint
2024-07-03 11:19:39 -05:00
Cal Corum
0d13fc939f Add s_type to /plays 2024-06-03 12:08:56 -05:00
Cal Corum
183e4bc91e Season 8 Decision Fix 2024-01-29 00:03:49 -06:00
Cal Corum
1ef4974218 Update stratplay.py
Added re24 to /batting and /pitching pulls
2024-01-22 23:22:51 -06:00
Cal Corum
fae1439365 Season 9 Additions 2024-01-14 22:44:23 -06:00
Cal Corum
025445bb99 Parameter modernization 2023-12-21 00:09:44 -06:00
Cal Corum
1168d7abaa Param updates to /plays 2023-12-04 13:38:53 -06:00
Cal Corum
342eb50362 Update stratplay.py
Add page_num param to play queries
2023-11-29 09:57:23 -06:00
Cal Corum
85b855492f Update stratplay.py
Add pitcher_team_id to raw plays
2023-11-05 00:53:51 -05:00
Cal Corum
9f635630e5 Added error check for pitchers with 0 ABs 2023-10-14 23:44:31 -05:00
Cal Corum
523b0a760e Add GHOST to position list 2023-10-04 23:25:25 -05:00
Cal Corum
c9655b8266 Added player_name param to /awards 2023-09-17 21:38:31 -05:00
Cal Corum
ff27abd408 Updated /plays/fielding 2023-09-17 11:47:45 -05:00
Cal Corum
b8c1096b86 Added play_num param to /plays 2023-09-16 18:36:50 -05:00
Cal Corum
1fa2a207ee Update csv exports 2023-09-15 22:38:37 -05:00
Cal Corum
761a279fc8 Added complex_to_csv 2023-09-15 01:29:00 -05:00
Cal Corum
63641dafb3 Update db_engine.py
Handle count() == 0 bug
2023-09-15 00:36:22 -05:00
Cal Corum
5fae0a30df Add query_to_csv 2023-09-15 00:03:23 -05:00
Cal Corum
bc37568c8e Update stratplay.py
Fix SB stats in playergame group_by
2023-09-11 23:19:14 -05:00
Cal Corum
d8ef59dae0 Stat updates for website 2023-09-10 19:16:36 -05:00
Cal Corum
5e773b3076 Update stratplay.py
Fixed woba bug with 1 PA & 1 IBB
2023-09-01 12:41:47 -05:00
Cal Corum
f9c578187e Update stratplay.py
- Added hit param to /plays
- Added to /plays/batting and /plays/pitching:
-- "league"  group_by option
-- inning param
-- rbi% output
2023-08-31 11:41:34 -05:00
Cal Corum
b3d2854210 Added left on base stats 2023-08-29 15:04:02 -05:00
Cal Corum
f6e9e6c7fd Standings updates
Added /standings/team/{id} endpoint
Fixed pythag calculation
2023-08-24 14:29:07 -05:00
Cal Corum
5110d8b497 Fix WC GB bug 2023-08-23 11:25:11 -05:00
Cal Corum
280280855c Update stratplay.py
- Added min_wpa and max_wpa to /plays and /plays/batting
- Added newest and oldest to sort options in /plays
- Added playergame and teamgame to group_by in /plays/batting and /plays/pitching
2023-08-22 16:35:59 -05:00
Cal Corum
211055d8b3 Update stratplay.py
added is_scoring_play
added _ to is_defender_or_catcher
2023-08-22 10:30:17 -05:00
Cal Corum
1b653943a5 Update rest_ip from int to float 2023-08-19 01:14:55 -05:00
Cal Corum
3ebf9698b2 Added obc and risp as parameters to plays/batting and /pitching 2023-08-18 14:52:43 -05:00
Cal Corum
85c8b441fa Update standings calculations 2023-08-11 09:32:35 -05:00
Cal Corum
03956191ab Update stratplay.py
add catcher & defender checks
2023-08-09 16:00:38 -05:00
Cal Corum
b259f8b693 Update stratplay.py
Add teamposition grouping
2023-08-07 15:09:20 -05:00
Cal Corum
08e54e10a1 Update stratplay.py
Add position grouping to /fielding
Add rate stats to /pitching
2023-08-07 10:35:30 -05:00
Cal Corum
17e9ed100a Add OPS to pitching and batting plays 2023-08-07 10:17:35 -05:00
Cal Corum
505d0a1a8a Add divisions, update standings 2023-08-05 00:28:00 -05:00
Cal Corum
474448556e Update stratplay.py 2023-08-03 23:05:20 -05:00
Cal Corum
6396250bf6 Add baserunning stats to /plays/batting 2023-08-03 22:20:58 -05:00
Cal Corum
cc1cb66593 Update stratplay.py
First pass at offensive stat totals
2023-08-01 23:46:46 -05:00
Cal Corum
302d3fe3ac add game_id param to decisions 2023-07-31 23:02:13 -05:00
Cal Corum
147b77b851 add wpa sort to plays 2023-07-31 00:29:17 -05:00
Cal Corum
cc3ff1d071 Add managers to /games 2023-07-31 00:29:04 -05:00
Cal Corum
2d235eb6f0 add /wipe/game 2023-07-29 01:35:39 -05:00
Cal Corum
40df835d98 /plays and /decisions
Added /plays validators for scorecard, first pass at /decisions
2023-07-29 00:13:07 -05:00
Cal Corum
5718ce1af9 /injuries fully functional 2023-07-27 23:41:57 -05:00
Cal Corum
5a5146c1cf Added logging to each router 2023-07-26 14:06:21 -05:00
Cal Corum
6e299f01cb /plays fully functional 2023-07-26 13:14:30 -05:00
Cal Corum
be229c3236 Added /plays 2023-07-26 08:31:43 -05:00
Cal Corum
dd027f7fa0 Added /games 2023-07-25 00:19:33 -05:00
Cal Corum
6c03eabfe3 Season 8 Draft Fixes 2023-07-24 23:04:26 -05:00
Cal Corum
8f316fb406 Season 8 updates to players 2023-07-17 23:09:04 -05:00
Cal Corum
115a50c50a Typo fixes 2023-07-17 23:08:53 -05:00
Cal Corum
1f007c654c Add sorting to draftpicks 2023-07-17 23:08:37 -05:00
Cal Corum
8b202fad1a Added draftdata and keepers 2023-07-17 23:08:24 -05:00
Cal Corum
e687629485 Added /teams roster pull 2023-07-09 10:18:20 -05:00
Cal Corum
635baa91ad Bug fixes 2023-06-27 10:18:20 -05:00
Cal Corum
48e3089e50 Added /awards 2023-06-21 14:39:06 -05:00
Cal Corum
449dafcfae Add short_output in /results 2023-06-21 10:05:33 -05:00
Cal Corum
5d7780a920 Updated ip_min in /pitchingstats 2023-06-21 10:05:16 -05:00
Cal Corum
0f436cf74b Added /managers 2023-06-21 10:05:01 -05:00
Cal Corum
1759932643 Add csv support for /players 2023-06-21 10:04:51 -05:00
Cal Corum
8f53d83d9e Added logging to dependencies, added week parameter to stats/totals 2023-05-27 11:16:52 -05:00
Cal Corum
c8aad86d3d Finished /fieldingstats/totals 2023-05-26 13:42:10 -05:00
Cal Corum
fb29f8bff3 Update with Sheets testing
Changed to /battingstats/totals
Updated some parameters to queries
2023-05-26 12:48:40 -05:00
Cal Corum
9bfa9c86dc Added /draftlist 2023-05-13 00:16:09 -05:00
Cal Corum
63491a7b62 Added /draftpicks 2023-05-12 15:28:34 -05:00
Cal Corum
d5cfaaa475 Batting, Pitching, and Fielding stats complete 2023-05-10 16:31:52 -05:00
Cal Corum
3bd4150da5 Batstats and pitchstats 2023-05-08 09:02:41 -05:00
Cal Corum
782804424d Fix relative package issues 2023-05-05 11:06:11 -05:00
Cal Corum
54b0485599 /standings, /teams, /transactions added 2023-03-22 15:56:10 -05:00
Cal Corum
0c7712cd78 Added /schedules and /results 2023-03-22 10:42:55 -05:00
Cal Corum
7ac8b752ec Initial commit
File structure in place
/players and /current built
2023-03-21 16:09:46 -05:00