Commit Graph

165 Commits

Author SHA1 Message Date
Cal Corum
8c039dedf8 Fix DateTimeField defaults for PostgreSQL compatibility
Paperdex and GauntletRun models used int timestamps as defaults which
worked in SQLite but fail in PostgreSQL. Changed to datetime.now.
2026-01-31 15:56:33 -06:00
Cal Corum
ab1a25aabc Bump version to 1.5.2 - PostgreSQL timestamp fixes
Fixed 17 timestamp conversion issues where Discord bot sends
milliseconds but PostgreSQL uses DateTimeField.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 23:02:31 -06:00
Cal Corum
5120963e18 Add .dockerignore
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:47:07 -06:00
Cal Corum
be7212032f Add local utility files to gitignore
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:46:56 -06:00
Cal Corum
af94a78ccf Bump version to 1.5.1
Preparing for bugfix release with PostgreSQL timestamp fixes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:46:10 -06:00
Cal Corum
1f78bd188b Fix missed timestamp issues in stats POST handlers
- Fix batstats.py and pitstats.py POST handlers to convert timestamps
- Fix Pydantic model defaults from *100000 to *1000 (wrong multiplier)

Found during second-pass audit.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:45:15 -06:00
Cal Corum
f4aafa35e7 Fix PostgreSQL timestamp conversion for stats GET filters
Convert milliseconds to datetime for created filter in batstats.py
and pitstats.py GET endpoints.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:41:00 -06:00
Cal Corum
f3b0b90860 Fix PostgreSQL timestamp handling in gauntletruns.py
- Convert milliseconds to datetime for GET filters (created_after/before, ended_after/before)
- Fix is_active filter to use is_null() instead of comparing to 0
- Fix PATCH to use datetime.now() instead of int timestamps
- Fix POST to convert timestamps and use None for nullable ended field
- Update Pydantic model defaults to None instead of int

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:39:45 -06:00
Cal Corum
e1c39cfb17 Fix PostgreSQL timestamp conversion for GET filters
Convert milliseconds timestamps to datetime for created_after filter
in notifications and created_after/before filters in paperdex.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:38:06 -06:00
Cal Corum
127c4fca65 Fix PostgreSQL timestamp conversion for POST/PATCH endpoints
Convert milliseconds timestamps from Discord bot to datetime objects
for PostgreSQL DateTimeField columns in notifications, packs, paperdex,
and rewards routers. Also fix rewards GET created_after filter.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 22:37:31 -06:00
Cal Corum
cb89a61196 Fix PostgreSQL upsert column names and CSV null handling
- Fix upsert_many() to use column_name for EXCLUDED references
  (ForeignKeyField columns end in _id, e.g., batter -> batter_id)
- Add null checks in batting/pitching CSV output for player, team, game
  fields to prevent 'NoneType' not subscriptable errors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 17:28:40 -06:00
Cal Corum
3dce457463 Fix flashback cardset legality and rewards timestamp handling
- Add 2018 Promos (14) and 2022 Promos (4) to flashback mode legal cardsets
- Convert Unix timestamps to datetime in rewards POST/PATCH for PostgreSQL

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 15:08:21 -06:00
Cal Corum
23bf59e3db Add production deployment config and fix stringified list parsing
- Fix /legal-check endpoint to handle card_ids passed as stringified list
- Add compose.production.yml for akamai deployment (pd_api container)
- Add migrate_missing_data.py script for filling gaps from initial migration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 14:03:07 -06:00
Cal Corum
b063b73f92 Address documentation gaps from review
- Added Prerequisites section with software/infrastructure requirements
- Added pre-migration steps: stop API, password file creation
- Added PostgreSQL 15+ schema permission grant
- Added post-migration VACUUM ANALYZE step
- Added Troubleshooting section with common errors and solutions
- Added verification queries for debugging
- Added expected record counts table
- Added connection string for external tools
- Expanded checklist with pre/post sections
- Added monitoring guidance
- Clarified CRITICAL warnings about data consistency
2026-01-27 15:27:18 -06:00
Cal Corum
ea5c047b15 Update migration guide with finalized production plan
- Updated test results with final migration metrics (549,788 records)
- Documented all tested endpoints with status
- Added complete step-by-step production migration plan
- Included rollback procedures and deployment checklist
- Documented known limitations and connection details
2026-01-27 14:03:05 -06:00
Cal Corum
94c8564282 Fix migration order: move gamerewards after player table
gamerewards has a FK to player (player_id), so it must be migrated
after the player table. Previously this caused the Pablo Sanchez Card
reward (id=9, player_id=9399) to fail with FK violation.
2026-01-27 10:41:54 -06:00
Cal Corum
392833a5d9 Add missing GROUP BY to decisions/rest endpoint for PostgreSQL
PostgreSQL requires GROUP BY for all non-aggregated columns when using
aggregate functions. Added group_by(pitcher, game) to the StratPlay query
that calculates pitcher innings in the /decisions/rest endpoint.
2026-01-26 22:01:38 -06:00
Cal Corum
92fc101e38 Fix PostgreSQL compatibility for GROUP BY queries and aggregations
- Fix NULL handling for FK checks in stratplays.py: use x.field_id instead
  of x.field to avoid triggering FK lookups on potentially missing rows
- Cast boolean is_start to integer for SUM() - PostgreSQL cannot sum booleans
- Add missing GROUP BY clause to Decision aggregate query
- Add Case import for boolean-to-integer casting
- Update migration script with boolean/datetime column mappings
- Exclude legacy battingstat/pitchingstat tables from migration
- Add comprehensive POSTGRES_MIGRATION_GUIDE.md documentation

Tested: /plays/batting and /plays/pitching endpoints work with group_by=player
2026-01-26 21:59:25 -06:00
Cal Corum
0cba52cea5 PostgreSQL migration: Complete code preparation phase
- Add db_helpers.py with cross-database upsert functions for SQLite/PostgreSQL
- Replace 12 on_conflict_replace() calls with PostgreSQL-compatible upserts
- Add unique indexes: StratPlay(game, play_num), Decision(game, pitcher)
- Add max_length to Team model fields (abbrev, sname, lname)
- Fix boolean comparison in teams.py (== 0/1 to == False/True)
- Create migrate_to_postgres.py with ID-preserving migration logic
- Create audit_sqlite.py for pre-migration data integrity checks
- Add PROJECT_PLAN.json for migration tracking
- Add .secrets/ to .gitignore for credentials

Audit results: 658,963 records across 29 tables, 2,390 orphaned stats (expected)

Based on Major Domo migration lessons learned (33 issues resolved there)
2026-01-25 23:05:54 -06:00
Cal Corum
fbe8623eb4 Merge branch 'main' into postgres-migration 2026-01-25 22:53:35 -06:00
Cal Corum
7cf507e3c2 Pin numpy<2 for older CPU compatibility
NumPy 2.x requires X86_V2 instruction set (SSE4.2/AVX) which
the production server CPU doesn't support. Pin to numpy 1.x
to avoid RuntimeError on startup.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 13:17:07 -06:00
Cal Corum
09924faea5 Normalize Player.franchise to city-agnostic values
- Add SQL migration script to update all franchise values
- Change AI roster queries from Team.lname to Team.sname
- Add FRANCHISE_NORMALIZE helper for bulk imports
- Update St Louis Cardinals hardcoded fix

Enables cross-era player matching for AI rosters (fixes Oakland Athletics issue)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 12:00:45 -06:00
Cal Corum
bf1601c9a0 Add VERSION file for docker build tracking
Initial version: 1.5

This file tracks the current version for Docker builds. When building
and pushing new versions, this file will be updated and the commit
will be tagged with the version number.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 09:24:25 -06:00
Cal Corum
a34e553b25 2005 Live Series Updates 2025-11-08 18:25:08 -06:00
Cal Corum
ad1f28b7df CLAUDE: Add QUICK_START.md with step-by-step testing guide 2025-11-07 14:07:17 -06:00
Cal Corum
cac8e7d126 CLAUDE: Comment out API service - prevents race condition in db_engine.py
- db_engine.py calls db.create_tables() at import time
- Multiple gunicorn workers cause duplicate key violations
- Run API locally for better development experience
- Keeps postgres and adminer services only
2025-11-07 14:07:13 -06:00
Cal Corum
e9f70b7ed0 CLAUDE: Fix PostgreSQL startup - use local directory instead of volume
- Switch from Docker volume to local directory mount to avoid space issues
- Comment out API service (run locally for development)
- Create logs/database directory
- Add postgres_data/ to .gitignore
- Fixes 'No space left on device' error
2025-11-07 13:30:37 -06:00
Cal Corum
08460c3884 CLAUDE: Change Adminer port to 8081 to avoid conflict with discord-app 2025-11-07 13:16:02 -06:00
Cal Corum
3e0445c70a CLAUDE: Fix YAML syntax in docker-compose.yml - comment out API service properly 2025-11-07 13:07:48 -06:00
Cal Corum
39a7d59fcd CLAUDE: Add docker-compose.yml and quickstart guide
- PostgreSQL 17 Alpine container with health checks
- Adminer database UI on port 8080
- Persistent volumes for data
- Environment variable support via .env
- Comprehensive quickstart guide with common commands
- Troubleshooting section
- Production considerations
- Update .gitignore to allow base docker-compose.yml
2025-11-07 13:07:23 -06:00
Cal Corum
0198965739 CLAUDE: Update .gitignore to explicitly ignore .env files
- Add .env and environment file patterns
- Add database backup patterns
- Ensures sensitive configuration is never committed
2025-11-07 12:53:06 -06:00
Cal Corum
4d40d8fd3f CLAUDE: Add .env.example with comprehensive configuration guide
- Documents all environment variables
- Includes SQLite and PostgreSQL configurations
- Provides example configurations for different environments
- Adds security notes and best practices
- Includes migration notes for PostgreSQL transition
2025-11-07 11:53:23 -06:00
Cal Corum
69ac31bbe3 CLAUDE: Add migration progress tracking document 2025-11-07 10:54:42 -06:00
Cal Corum
0d123be090 CLAUDE: Add psycopg2-binary to requirements for PostgreSQL support 2025-11-07 10:53:27 -06:00
Cal Corum
1517283114 CLAUDE: Fix GROUP BY queries for PostgreSQL compatibility
- Refactor get_batting_totals() to conditionally build SELECT fields based on group_by parameter
- Refactor get_pitching_totals() with same pattern
- Ensures all non-aggregated SELECT fields are included in GROUP BY clause
- Based on successful Major Domo migration pattern
2025-11-07 10:25:00 -06:00
Cal Corum
f6e8aa7108 CLAUDE: Add PostgreSQL support and table names to models
- Add environment-based PostgreSQL configuration to db_engine.py
- Add table_name to all 30 models (Meta class)
- Update db_migrations.py to auto-select migrator based on DB type
- Add comprehensive PostgreSQL migration plan document
2025-11-07 10:23:14 -06:00
Cal Corum
db0635b01d Added search endpoints 2025-10-08 14:21:44 -05:00
Cal Corum
b20d0cdf88 Adding card variant support 2025-07-22 09:26:23 -05:00
Cal Corum
adaa8206c8 Players bug fix 2025-05-29 22:19:34 -05:00
Cal Corum
2791e1964b Gauntlet 8 updates 2025-05-29 22:19:19 -05:00
Cal Corum
acb65ef47c Gauntlet 7 cardsets 2024-12-23 16:13:05 -06:00
Cal Corum
0b8234f9d6 Add poop_max to game summary 2024-12-23 10:14:02 -06:00
Cal Corum
21fe5c419a Flip image libraries due to white bar bug 2024-11-04 23:17:07 -06:00
Cal Corum
1e4569dfbf Clean up root_validators
Remove root_path from FastAPI
Update Season 8 Cardsets
Force pydantic 1.x
2024-11-03 01:46:40 -05:00
Cal Corum
17416cd50f Log mlbplayer dupes
Update cardsets for season 8
2024-11-02 23:44:32 -05:00
Cal Corum
2a2961983a Added All-Star teams to record 2024-08-19 14:38:20 -05:00
Cal Corum
a265b83c63 Add support for exhibition games 2024-07-14 13:23:15 -05:00
Cal Corum
18a6ed2ebd Support for Exhibition games & Swagger updates 2024-07-11 15:07:23 -05:00
Cal Corum
75e2f05f48 Add support for Swagger 2024-07-11 15:06:58 -05:00
Cal Corum
179947b536 Add schema privacy to docs 2024-07-07 22:53:29 -05:00