Cal Corum
|
b5677d0c55
|
CLAUDE: Phase 3.5 Planning - Code Polish & Statistics System
Completed comprehensive planning for Phase 3.5 with focus on production
readiness through materialized views approach for statistics.
Planning Documents Created:
- STAT_SYSTEM_ANALYSIS.md: Analysis of existing major-domo schema
* Reviewed legacy BattingStat/PitchingStat tables (deprecated)
* Analyzed existing /plays/batting and /plays/pitching endpoints
* Evaluated 3 approaches (legacy port, modern, hybrid)
- STAT_SYSTEM_MATERIALIZED_VIEWS.md: Recommended approach
* PostgreSQL materialized views (following major-domo pattern)
* Add stat fields to plays table (18 new columns)
* 3 views: batting_game_stats, pitching_game_stats, game_stats
* PlayStatCalculator service (~150 lines vs 400+ for StatTracker)
* 80% less code, single source of truth, always consistent
- phase-3.5-polish-stats.md: Complete implementation plan
* Task 1: Game Statistics System (materialized views)
* Task 2: Authorization Framework (WebSocket security)
* Task 3: Uncapped Hit Decision Trees
* Task 4: Code Cleanup (remove TODOs, integrate features)
* Task 5: Integration Test Infrastructure
* Estimated: 16-24 hours (2-3 days)
NEXT_SESSION.md Updates:
- Phase 3.5 ready to begin (0% → implementation phase)
- Complete task breakdown with acceptance criteria
- Materialized view approach detailed
- Commit strategy for 3 separate commits
- Files to review before starting
Implementation Status Updates:
- Phase 3: 100% Complete (688 tests passing)
- Phase 3F: Substitution system fully tested
- Phase 3.5: Planning complete, ready for implementation
- Updated component status table with Phase 3 completion
Key Decisions:
- Use materialized views (not separate stat tables)
- Add stat fields to plays table
- Refresh views after game completion + on-demand
- Use legacy field names (pa, ab, run, hit) for compatibility
- Skip experimental fields (bphr, xba, etc.) for MVP
Benefits of Materialized Views:
- 80% less code (~400 lines → ~150 lines)
- Single source of truth (plays table)
- Always consistent (stats derived, not tracked)
- Follows existing major-domo pattern
- PostgreSQL optimized (indexed, cached)
Next Steps:
1. Implement PlayStatCalculator (map PlayOutcome → stats)
2. Add stat fields to plays table (migration 004)
3. Create materialized views (migration 005)
4. Create BoxScoreService (query views)
5. Refresh logic after game completion
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-06 16:08:23 -06:00 |
|