strat-gameplay-webapp/.claude
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
..
archive Documentation Archival 2025-11-01 01:17:15 -05:00
commands CLAUDE: Update project plan for Week 7 continuation 2025-10-30 01:24:51 -05:00
implementation CLAUDE: Phase 3.5 Planning - Code Polish & Statistics System 2025-11-06 16:08:23 -06:00
ENVIRONMENT.md CLAUDE: Complete Phase 1 backend infrastructure setup 2025-10-21 19:46:16 -05:00
force-claude-reads.md CLAUDE: Initial project setup - documentation and infrastructure 2025-10-21 16:21:13 -05:00
PHASE_1_CATCHUP_PLAN.md CLAUDE: Reorganize Week 6 documentation and separate player model specifications 2025-10-25 23:48:57 -05:00
PHASE_1_STATUS_SUMMARY.md CLAUDE: Reorganize Week 6 documentation and separate player model specifications 2025-10-25 23:48:57 -05:00
refactor_overview.md CLAUDE: Add refactor planning and session documentation 2025-10-25 22:19:59 -05:00
status-2025-10-22-0113.md CLAUDE: Complete Week 4 - State Management & Persistence 2025-10-22 12:01:03 -05:00
status-2025-10-22-1147.md CLAUDE: Complete Week 4 - State Management & Persistence 2025-10-22 12:01:03 -05:00
status-2025-10-24-1430.md CLAUDE: Add refactor planning and session documentation 2025-10-25 22:19:59 -05:00