Commit Graph

25 Commits

Author SHA1 Message Date
Cal Corum
c5e1fb44a6 Simplify and deduplicate codebase (-261 lines)
Consolidate shared helpers (format_rating, format_swar, tier_style,
format_relative_time) into widgets/mod.rs and screens/mod.rs. Replace
heap allocations with stack arrays and HashSets, parallelize DB queries
with tokio::try_join, wrap schema init in transactions, use OnceLock for
invariant hashes, and fix clippy warnings. Auto-sync on dashboard mount
when last sync >24h ago. All 105 tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 20:07:23 -06:00
Cal Corum
defe741aba Fix stale screen count and standings description in CLAUDE.md
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 18:48:38 -06:00
Cal Corum
9863f89309 Implement Standings screen with DB-cached two-phase loading
Add league standings with Division and Wild Card tabs, fetched from API
with SQLite cache for instant display on screen open. Document 11 new
future features in project plan and add cargo check post-edit hook.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 18:31:55 -06:00
Cal Corum
944d5a281b Update CLAUDE.md to reflect Phase 5 completion
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 16:23:16 -06:00
Cal Corum
ad8cf33139 Fix Phase 5 live testing bugs across all four new screens
Roster: sWAR only sums majors, stateful table rendering for j/k scroll,
rows sorted batters-first for correct selection mapping.
Matchup: initial focus highlight, descriptive sort key hints, state
cached on nav-away to preserve opponent/pitcher selections.
Lineup: load/delete/clear promoted to work from any focus, load selector
popup anchored correctly, delete confirmation prompt.
Settings: API key toggle changed to Ctrl+T so t can be typed, per-field
yellow change markers, sWAR/cap formatting to two decimal places.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 15:59:09 -06:00
Cal Corum
b6da926258 Implement Phase 5: Roster, Matchup, Lineup, and Settings screens
Replace all four stub screens with full implementations. Wire up nav bar
with [r/m/l/S] keys and Box<State> ActiveScreen variants. Roster shows
tabbed batter/pitcher tables with card ratings. Matchup adds standalone
analysis with sort modes. Lineup provides two-panel builder with
save/load/delete. Settings offers form-based TOML config editing with
live team validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 14:29:50 -06:00
Cal Corum
5968901cb2 Add local CSV card data for Rust importer integration testing
Copies BatterCalcs.csv and PitcherCalcs.csv into rust/docs/sheets_export/
so the Rust CSV importer can find them at the default path. Verified
import produces identical results to Python DB (490 batters, 502 pitchers).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 12:08:04 -06:00
Cal Corum
a033a28b5a Count all eligible positions in dashboard position coverage
Previously only counted pos_1; now uses Player::positions() to tally
all position fields (pos_1-pos_8) so multi-position players are counted
at each eligible position.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 11:58:14 -06:00
Cal Corum
3e736442c7 Redesign dashboard with roster health, card coverage, and sync refresh
- Add position coverage, IL players, missing card warnings, and detailed
  sync status sections to the dashboard
- Fix team sync to include IL/MiL teams (active_only=false), matching
  Python behavior so get_my_roster() finds WVIL/WVMiL teams
- Re-fetch all dashboard data after successful sync so changes reflect
  immediately without navigating away
- Add sWAR budget bar (90-100% range) with color thresholds from
  Team.salary_cap
- Add team-scoped missing card queries and bulk sync status query
- Mark Phase 2 and Phase 3 project plans as complete

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 11:52:38 -06:00
Cal Corum
60b397b529 Fix sync errors: string move_id, FK constraints on connection pool
API returns move_id as string ("Season-013-Week-11-1772073335"), not
i64. Also disable foreign_keys at pool level via SqliteConnectOptions
since transactions reference players/teams that may not exist locally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 10:50:27 -06:00
Cal Corum
a18c0431d1 Fix sync JSON parse error: Discord snowflake IDs are strings, not i64
The API returns gmid/gmid2 as quoted strings ("258104532423147520")
to avoid JavaScript precision loss. Changed types to Option<String>.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 08:07:03 -06:00
Cal Corum
bf7c3f870f Add file-based logging to avoid TUI corruption from stderr output
Errors were only visible in the truncated status bar notification.
Add tracing-appender to write to data/sba-scout.log with env-filter
support (RUST_LOG), and add tracing::error! calls alongside all
notification-only error paths for full diagnostic visibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 08:04:33 -06:00
Cal Corum
6d2b11a797 Implement Phase 4: async TUI with Dashboard and Gameday screens
Replace blocking event loop with tokio::select! over EventStream, mpsc
channel, and tick interval. Add message bus architecture with AppMessage
enum for background task results. Implement Dashboard with roster summary
cards and API sync, and Gameday with cascading team/pitcher selectors,
matchup table, and 9-slot lineup management with save/load.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 07:09:25 -06:00
Cal Corum
ebe4196bfc Implement Phase 3: calc layer with matchup scoring, league stats, and score cache
Port the Python calc layer to Rust: league stat distributions (avg excludes zeros,
stdev N-1 includes zeros), weighted standardized matchup scoring with switch-hitter
resolution and pitcher inversion, and SHA-256-validated score cache with automatic
rebuild after card imports. 105 tests passing (76 unit + 5 integration + 24 DB).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 23:35:01 -06:00
Cal Corum
3c70ecc71a Implement Phase 2: API client, sync pipeline, and CSV card importers
Port the full data ingestion layer from Python to Rust:
- Typed API client with 10 endpoints, serde response types, and error handling
- Team/player/transaction sync with proper upsert semantics (preserves hand field)
- Batter and pitcher CSV importers with 40+ column mappings each
- Parse helpers for float/int/endurance with 21 unit tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-27 22:56:50 -06:00
Cal Corum
3c0c206aba Add test scaffold and mark Phase 1 tasks complete
Set up lib.rs for integration test access, add 50 tests covering
calc engine (weights, standardization), model helpers (Player positions,
Lineup JSON roundtrips), and full query layer (in-memory SQLite).
Update PHASE1_PROJECT_PLAN.json to reflect all 12 tasks completed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 20:02:01 -06:00
Cal Corum
2005307b7a Implement Phase 1 foundation: DB schema, queries, and config integration
Wire up the full data pipeline for the Rust TUI rewrite:
- SQL schema creation for all 9 tables with correct types, FKs, and constraints
- 20 async query functions (teams, players, cards, lineups, sync status, cache)
- Config loading via figment integrated into main.rs startup flow
- App struct now holds SqlitePool and Settings for screen access
- Roster aggregate query and Lineup JSON helper methods
- Added csv, sha2, regex crates for upcoming phases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 19:17:36 -06:00
Cal Corum
6ddbd82f7c Add Rust project scaffold for TUI rewrite
Initialize rust/ subdirectory with ratatui + tokio + sqlx stack,
mirroring the Python module structure. Includes all DB models,
config loader, matchup scoring logic, and screen stubs that
compile cleanly with cargo check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 08:40:42 -06:00
Cal Corum
7afe4a5f55 Fix TUI corruption from logging and improve sync error handling
- Redirect all logging to data/logs/sba_scout.log instead of stderr
- Prevents log output from corrupting the Textual TUI display
- Add loading spinner for sync operations to show progress
- Improve error messages for Cloudflare/API errors
- Add TROUBLESHOOTING.md guide for common sync issues
- Exclude data/ directory from git

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-10 16:18:57 -06:00
Cal Corum
0338fe1b38 Merge remote main branch 2026-01-28 13:54:59 -06:00
Cal Corum
acff270579
Initial commit 2026-01-28 13:52:42 -06:00
Cal Corum
3adc064a42 Fix Gameday lineup row selection and deselect behavior
- Fix bug where clicking to select a player in the middle of the lineup
  would operate on the last added player instead of the clicked row
- Deselect now requires clicking the same row twice (for screenshots)
- Clicking the table after deselect re-enables selection mode
- Fix main.py to actually launch the TUI app
- Add CLAUDE.md with codebase documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-28 13:47:03 -06:00
Cal Corum
9c59c79c98 Add Settings screen with YAML configuration
- New Settings screen (press 'x') for configuring app settings
- Settings stored in data/settings.yaml (user-editable)
- Editable fields: team abbrev, season, API URL, API key (masked), theme
- Team validation against database before saving
- Read-only team info display from database (name, sWAR cap, ID)
- Load order: defaults -> .env -> settings.yaml
- Added pyyaml dependency
2026-01-27 16:24:28 -06:00
Cal Corum
3c76ce1cf0 Add Lineup Builder, Gameday screen, and matchup scoring system
Features:
- Lineup Builder screen: set batting order, assign positions, save/load lineups
- Gameday screen: integrated matchup scout + lineup builder side-by-side
- Matchup Scout: analyze batters vs opposing pitchers with standardized scoring
- Standardized scoring system with league AVG/STDEV calculations
- Score caching for fast matchup lookups

Lineup Builder (press 'l'):
- Dual-panel UI with available batters and 9-slot lineup
- Keyboard controls: a=add, r=remove, k/j=reorder, p=change position
- Save/load named lineups, delete saved lineups with 'd'

Gameday screen (press 'g'):
- Left panel: team/pitcher selection with matchup ratings
- Right panel: lineup builder with live matchup ratings per batter
- Players in lineup marked with * in matchup list
- Click highlighted row to toggle selection for screenshots

Other changes:
- Dynamic season configuration (removed hardcoded season=13)
- Added delete_lineup query function
- StandardizedScoreCache model for pre-computed scores
- Auto-rebuild score cache after card imports
2026-01-25 14:09:22 -06:00
Cal Corum
5b307a91a6 Initial SBA Scout TUI application
- Dashboard with roster summary (Majors/Minors/IL counts, sWAR usage)
- Roster screen with tabbed view (Majors/Minors/IL) showing:
  - Batters table: Name, Hand, Positions, vL/vR/Ovr ratings, sWAR, Defense
  - Pitchers table: Name, Hand, Positions, vL/vR/Ovr ratings, sWAR, S/R/C endurance
- Card data importer from BatterCalcs/PitcherCalcs CSV exports
  - Imports pre-calculated vL/vR/Total ratings directly from spreadsheet
- API client for syncing players/teams from Major Domo league API
- SQLite database with SQLAlchemy async models
- Configurable settings via .env (team info, roster slots, sWAR cap)
- Placeholder screens for Matchup Scout, Lineup Builder, Transactions
2026-01-25 00:22:20 -06:00