Major Domo Database - PostgreSQL database service for SBA bot
Go to file
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
.claude/plans DB Error Handling 2025-08-20 19:33:40 -05:00
app CLAUDE: Season batting stats table and selective update system 2025-08-23 22:18:27 -05:00
scripts CLAUDE: Season batting stats table and selective update system 2025-08-23 22:18:27 -05:00
test-storage CLAUDE: Phase 1 PostgreSQL migration fixes complete 2025-08-18 18:09:45 -05:00
.dockerignore Adding Git and Docker files 2023-02-21 11:53:02 -06:00
.env Local migration fully functional 2025-08-20 09:52:46 -05:00
.gitignore Local migration fully functional 2025-08-20 09:52:46 -05:00
=2.9.0 CLAUDE: Phase 1 PostgreSQL migration fixes complete 2025-08-18 18:09:45 -05:00
api_data_integrity_tests.py Local migration fully functional 2025-08-20 09:52:46 -05:00
CLAUDE.md CLAUDE: Season batting stats table and selective update system 2025-08-23 22:18:27 -05:00
comprehensive_api_integrity_tests.py DB Error Handling 2025-08-20 19:33:40 -05:00
COMPREHENSIVE_API_TEST_COVERAGE.md Local migration fully functional 2025-08-20 09:52:46 -05:00
create_season_batting_stats_table.sql CLAUDE: Season batting stats table and selective update system 2025-08-23 22:18:27 -05:00
CUSTOM_COMMANDS_MIGRATION.md CLAUDE: Add custom commands system with migration from legacy database 2025-08-17 16:31:39 -05:00
DATA_SANITIZATION_TEMPLATE.md CLAUDE: Phase 1 PostgreSQL migration fixes complete 2025-08-18 18:09:45 -05:00
db_engine.py DB Error Handling 2025-08-20 19:33:40 -05:00
docker-compose.yml CLAUDE: Season batting stats table and selective update system 2025-08-23 22:18:27 -05:00
Dockerfile Local migration fully functional 2025-08-20 09:52:46 -05:00
Dockerfile.optimized Local migration fully functional 2025-08-20 09:52:46 -05:00
LICENSE Initial commit 2023-02-19 21:42:32 -06:00
main.py Merge pull request #2 from calcorum/api-rebuild 2023-07-24 23:06:53 -05:00
migrate_custom_commands.py CLAUDE: Add custom commands system with migration from legacy database 2025-08-17 16:31:39 -05:00
migrate_to_postgres.py DB Error Handling 2025-08-20 19:33:40 -05:00
migration_issues_tracker.md Local migration fully functional 2025-08-20 09:52:46 -05:00
MIGRATION_METHODOLOGY.md CLAUDE: Phase 1 PostgreSQL migration fixes complete 2025-08-18 18:09:45 -05:00
MIGRATION_QUICK_REFERENCE.md CLAUDE: Add custom commands system with migration from legacy database 2025-08-17 16:31:39 -05:00
migrations.py Season 9 Additions 2024-01-14 22:44:23 -06:00
optimize_postgres.sql Local migration fully functional 2025-08-20 09:52:46 -05:00
pd_master.db Logging updates 2024-12-16 09:03:23 -06:00
POSTGRESQL_MIGRATION_DATA_INTEGRITY_ISSUE.md Local migration fully functional 2025-08-20 09:52:46 -05:00
POSTGRESQL_OPTIMIZATIONS.md Local migration fully functional 2025-08-20 09:52:46 -05:00
PRODUCTION_MIGRATION_CHECKLIST.md CLAUDE: Phase 1 PostgreSQL migration fixes complete 2025-08-18 18:09:45 -05:00
quick_data_comparison.py Local migration fully functional 2025-08-20 09:52:46 -05:00
requirements.txt CLAUDE: Phase 1 PostgreSQL migration fixes complete 2025-08-18 18:09:45 -05:00
reset_postgres.py DB Error Handling 2025-08-20 19:33:40 -05:00
run_optimization.py Local migration fully functional 2025-08-20 09:52:46 -05:00
test_migration_workflow.sh DB Error Handling 2025-08-20 19:33:40 -05:00
test_postgres.py DB Error Handling 2025-08-20 19:33:40 -05:00
test_requirements.txt Local migration fully functional 2025-08-20 09:52:46 -05:00
validate_migration.py DB Error Handling 2025-08-20 19:33:40 -05:00