Commit Graph

367 Commits

Author SHA1 Message Date
Cal Corum
35389cac24 fix: remove plaintext bearer token from warning logs (#7)
Replace all logging.warning(f'Bad Token: {token}') calls with
logging.warning('Bad Token: [REDACTED]') across 30 router files.
Full bearer tokens were being written to log files on auth failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:43:27 +00:00
cal
8283425b84 Merge pull request 'fix: consolidate redundant double-query in get_one_play (#14)' (#52) from ai/paper-dynasty-database#14 into next-release
Reviewed-on: #52
2026-03-05 03:36:25 +00:00
Cal Corum
f1d289a0e9 fix: consolidate redundant double-query in get_one_play (#14)
Reuse the result of get_or_none instead of discarding it and calling
get_by_id again, eliminating one unnecessary round-trip per request.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:35:59 +00:00
cal
110493d1b0 Merge pull request 'fix: compute CSV after appending data row in get_one_player (#12)' (#51) from ai/paper-dynasty-database-12 into next-release
Reviewed-on: #51
2026-03-05 03:32:21 +00:00
Cal Corum
0166c7dda4 fix: compute CSV after appending data row in get_one_player (#12)
return_val was assigned from DataFrame(data_list).to_csv() before the
player data row was appended to data_list, so the CSV response contained
only the header row. Moved the to_csv() call to after the append.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:32:09 +00:00
cal
d1728a804f Merge pull request 'fix: guard against None rating objects in pitcher sorting functions (#13)' (#50) from ai/paper-dynasty-database#13 into next-release
Reviewed-on: #50
2026-03-05 03:29:48 +00:00
Cal Corum
0948db0b49 fix: guard against None rating objects in pitcher sorting functions (#13)
Add None checks for vlval/vrval in get_total_ops inside sort_pitchers()
and sort_starters(). Returns float("inf") when ratings are missing so
pitchers without ratings sort to the end rather than raising AttributeError.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:25:28 +00:00
cal
1651ff1738 Merge pull request 'fix: document SQLite synchronous=0 pragma in db_engine.py (#20)' (#49) from ai/paper-dynasty-database#20 into next-release
Reviewed-on: #49
2026-03-05 03:23:50 +00:00
Cal Corum
870c753bf7 fix: document SQLite synchronous=0 pragma in db_engine.py (#20)
Add explanatory comment clarifying that synchronous=OFF is a dev-only
trade-off (production uses PostgreSQL), and describing the crash-corruption
risk and how WAL mode partially mitigates it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:23:30 +00:00
cal
341296b573 Merge pull request 'fix: centralize logging config in main.py (#26)' (#46) from ai/paper-dynasty-database#26 into next-release
Reviewed-on: #46
2026-03-05 03:22:28 +00:00
Cal Corum
053fcbab05 fix: centralize logging config in main.py — remove basicConfig from 32 files (#26)
Moved logging.basicConfig() to app/main.py as the single source of truth.
Removed duplicate (no-op) calls from app/db_engine.py, app/dependencies.py,
and all 30 router files in app/routers_v2/. Removed the now-unused LOG_DATA
dict and date/log_level locals from dependencies.py and db_engine.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:22:02 +00:00
cal
e7c8b59201 Merge pull request 'fix: batch-fetch PitchingCardRatings instead of per-row queries (#19)' (#44) from ai/paper-dynasty-database#19 into next-release
Reviewed-on: #44
2026-03-05 03:19:58 +00:00
Cal Corum
ae8c20ea1c fix: batch-fetch PitchingCardRatings instead of per-row queries (#19)
Replace two get_or_none calls per row in sort_pitchers and sort_starters
with a single batched SELECT for all card IDs, reducing N*2 queries to 1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:19:43 +00:00
cal
9096a4b976 Merge pull request 'fix: add type annotations to untyped path parameters (#27)' (#43) from ai/paper-dynasty-database#27 into next-release
Reviewed-on: #43
2026-03-05 03:18:49 +00:00
Cal Corum
5f86c8cb20 fix: add type annotations to untyped path parameters (#27)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:18:38 +00:00
cal
20f727a119 Merge pull request 'fix: remove duplicate ranking_max filter in get_teams (#21)' (#42) from ai/paper-dynasty-database#21 into next-release
Reviewed-on: #42
2026-03-05 03:17:50 +00:00
Cal Corum
86b4338b66 fix: remove duplicate ranking_max filter in get_teams (#21)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 16:01:52 -06:00
cal
761c0a6dab Merge pull request 'fix: replace 467 manual db.close() calls with middleware (#30)' (#33) from ai/paper-dynasty-database#30 into next-release
Reviewed-on: #33
2026-03-03 21:53:37 +00:00
Cal Corum
bcdbf2add1 fix: remove unused imports in PR #33 files
Removed 55 unused imports across 26 router files. Most were `db` imports
left over after the db.close() removal in the previous commit, plus
additional stale imports (scipy.stats, chunked, copy, base64, Html2Image,
pandas.DataFrame, pydantic.validator, etc.) that were already unused.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 15:52:56 -06:00
Cal Corum
8d86b3fec6 fix: replace 467 manual db.close() calls with middleware (#30)
Add db_session_middleware to main.py that opens the connection at the
start of each request and closes it in a try/finally block, ensuring
connections are always returned even on uncaught exceptions.

Remove all individual db.close() calls from 30 router files in
app/routers_v2/ — the middleware now handles all code paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 15:52:56 -06:00
cal
fe5635ef0e Merge pull request 'fix: use Field(default_factory) for offense_col random default (#24)' (#38) from ai/paper-dynasty-database-24 into next-release
Reviewed-on: #38
2026-03-03 21:46:46 +00:00
Cal Corum
6130eb993f fix: use Field(default_factory) for offense_col random default (#24)
Pydantic evaluates bare `random.randint(1, 3)` once at class definition
time, so every PlayerModel instance shared the same value. Replaced with
`pydantic.Field(default_factory=...)` so a new random value is generated
per instance.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 21:46:03 +00:00
cal
215c48a53e Merge pull request 'fix: remove dead roster fields from CSV in v1_cards_get_one (#25)' (#35) from ai/paper-dynasty-database-25 into next-release
Reviewed-on: #35
2026-03-03 21:45:14 +00:00
Cal Corum
6a2e8a2d2a fix: remove dead roster fields from CSV in v1_cards_get_one (#25)
Card model has no roster1/2/3 fields. Accessing them would raise
AttributeError at runtime. Removed the non-existent columns from
the CSV header and data row.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 21:44:59 +00:00
cal
d031553e03 Merge pull request 'fix: correct inverted TESTING env check and leading space in .env (#23)' (#40) from ai/paper-dynasty-database#23 into next-release
Reviewed-on: #40
2026-03-03 21:44:25 +00:00
Cal Corum
9fc7a9449e fix: correct inverted TESTING env check and leading space in .env (#23)
- Change `== 'False'` to `== 'True'` so TESTING=True routes to dev URL
- Fix leading space on TESTING=TRUE in .env so the var is actually set
- Update .env comment to match corrected logic

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 21:43:54 +00:00
cal
7b18962033 Merge pull request 'fix: respect is_ai=False in get_teams filter (#22)' (#41) from ai/paper-dynasty-database#22 into next-release
Reviewed-on: #41
2026-03-03 21:42:00 +00:00
Cal Corum
3e15acbb9d fix: respect is_ai=False in get_teams filter (#22)
`all_teams.where(Team.is_ai)` always filtered for AI teams regardless
of the caller's intent. Match the existing has_guide pattern and use
explicit boolean comparison so False is handled correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-03 21:38:50 +00:00
Cal Corum
2a660e9c19 docs: add next-release branch workflow to CLAUDE.md
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 10:56:03 -06:00
cal
4a4ed0ff2b Merge pull request 'fix: remove debug print(req.scope) from get_docs route (#31)' (#32) from ai/paper-dynasty-database#31 into next-release
Reviewed-on: #32
2026-03-03 16:52:38 +00:00
Cal Corum
65ad72c299 fix: remove debug print(req.scope) from get_docs route (#31)
All checks were successful
Build Docker Image / build (pull_request) Successful in 9m50s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 22:36:15 -06:00
cal
41c50dac4f Merge pull request 'ci: Fix act_runner auth for composite actions' (#5) from ci/fix-action-auth into main
All checks were successful
Build Docker Image / build (push) Successful in 53s
Reviewed-on: #5
2026-02-18 19:52:36 +00:00
cal
25c533ed3d Merge branch 'main' into ci/fix-action-auth
All checks were successful
Build Docker Image / build (pull_request) Successful in 47s
2026-02-18 19:49:03 +00:00
Cal Corum
ea71371b95 Fix act_runner auth: short-form local actions + full GitHub URLs
All checks were successful
Build Docker Image / build (pull_request) Successful in 46s
DEFAULT_ACTIONS_URL=self requires local actions use short form
(cal/gitea-actions/...) so the runner passes its auth token, and
GitHub actions use full URLs (https://github.com/...) to bypass
local resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 13:32:14 -06:00
cal
36f01a2d61 Merge pull request 'ci: Use Gitea API for tag creation' (#4) from ci/api-tags into main
All checks were successful
Build Docker Image / build (push) Successful in 42s
Reviewed-on: #4
2026-02-17 23:24:50 +00:00
Cal Corum
eff6c1136b ci: Use Gitea API for tag creation to avoid branch protection issues
All checks were successful
Build Docker Image / build (pull_request) Successful in 43s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 17:23:21 -06:00
cal
d3ffb89e6e Merge pull request 'ci: Switch to CalVer versioning' (#3) from ci/calver into main
Some checks failed
Build Docker Image / build (push) Failing after 43s
Reviewed-on: #3
2026-02-17 23:11:55 +00:00
Cal Corum
6622839ffa ci: Switch to CalVer (YYYY.MM.BUILD) with auto-generated versions
All checks were successful
Build Docker Image / build (pull_request) Successful in 43s
Remove manual semver validation from PR checks. Versions are now
auto-generated on merge to main by counting existing monthly tags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 17:10:31 -06:00
Cal Corum
b76c8166fa Remove CLAUDE.md from .gitignore
CLAUDE.md should be tracked in version control.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 17:10:25 -06:00
Cal Corum
e0d0ba59ff Optimize CLAUDE.md from 158 to 43 lines
Remove full router listing, production ops examples, and boilerplate.
Keep commands, architecture, environment table, and key constants.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 17:10:25 -06:00
cal
b6f1a85a49 Merge pull request 'ci: switch Docker build cache to type=registry' (#2) from ci/registry-cache into main
All checks were successful
Build Docker Image / build (push) Successful in 10m6s
2026-02-11 22:14:27 +00:00
cal
305e1b0ffa ci: switch Docker build cache from type=gha to type=registry
Some checks failed
Build Docker Image / build (pull_request) Failing after 14s
The gha cache backend silently fails on Gitea Actions due to Docker
networking issues between the Buildx builder container and the
act_runner cache server. Registry-based caching stores layers on
Docker Hub, which is more reliable for self-hosted runners.
2026-02-11 22:12:30 +00:00
cal
65c00800d2 Merge pull request 'postgres-migration' (#1) from postgres-migration into main
All checks were successful
Build Docker Image / build (push) Successful in 3m21s
Reviewed-on: #1
2026-02-05 19:43:13 +00:00
Cal Corum
737bde9b94 Add Gitea Actions CI/CD workflow for Docker builds
All checks were successful
Build Docker Image / build (pull_request) Successful in 6m12s
- Semantic version validation on PRs
- Automated Docker image builds and pushes to Docker Hub
- Discord notifications for build status
- Multi-tag strategy: latest, semver, commit hash

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 13:35:08 -06:00
Cal Corum
3d4e5280e0 Remove deprecated legacy files and reorganize documentation
- Delete deprecated root main.py (superseded by app/main.py)
- Delete deprecated root db_engine.py (superseded by app/db_engine.py)
- Delete legacy sheets.py (Google Sheets integration, unused)
- Archive db_migrations.py and SQL migrations to .claude/archive/
- Archive POSTGRES_MIGRATION_PLAN.md to .claude/archive/
- Move active documentation to docs/ directory

This cleanup removes ~10,000 lines of deprecated code and organizes
remaining documentation for better maintainability.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 13:34:09 -06:00
Cal Corum
2168f85924 Bump version to 1.5.5 2026-02-04 08:48:12 -06:00
Cal Corum
b8a6c6bd2c Fix KeyError: 'human' in gauntlet-9 CARDSETS
Added missing 'human' key to gauntlet-9 cardset configuration.
This was causing 500 errors when players tried to start gauntlet
games because the legal-check endpoint couldn't validate cards.

Error: KeyError: 'human' at app/routers_v2/cards.py:242
when checking CARDSETS[rarity_name]['human']

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-04 08:47:21 -06:00
Cal Corum
40c512c665 Add PostgreSQL compatibility fixes for query ordering
- Add explicit ORDER BY id to all queries for consistent results across SQLite and PostgreSQL
- PostgreSQL does not guarantee row order without ORDER BY, unlike SQLite
- Skip table creation when DATABASE_TYPE=postgresql (production tables already exist)
- Fix datetime handling in notifications (PostgreSQL native datetime vs SQLite timestamp)
- Fix grouped query count() calls that don't work in PostgreSQL
- Update .gitignore to include storage/templates/ directory

This completes the PostgreSQL migration compatibility layer while maintaining
backwards compatibility with SQLite for local development.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 10:39:14 -06:00
Cal Corum
0437eab92a Add missing card templates for PostgreSQL deployment
- Recovered player_card.html and related templates from old server
- Required for card generation endpoints (/players/{id}/battingcard)
- Fixes TemplateNotFound errors in production
2026-02-01 19:18:04 -06:00
Cal Corum
b6743f704b Bump version to 1.5.4 2026-01-31 16:07:06 -06:00