Commit Graph

381 Commits

Author SHA1 Message Date
cal
be02ba1e3f Merge pull request 'fix: remove broken live_update_batting stub endpoint (#10)' (#54) from ai/paper-dynasty-database#10 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #54
2026-03-07 03:22:08 +00:00
cal
3ddb7028f3 Merge pull request 'fix: replace broad except Exception blocks with DoesNotExist (#15)' (#48) from ai/paper-dynasty-database#15 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #48
2026-03-07 03:18:56 +00:00
cal
f1769966a0 Merge pull request 'fix: batch BattingCard/BattingCardRatings lookups in lineup builder (#18)' (#45) from ai/paper-dynasty-database#18 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #45
2026-03-07 03:16:12 +00:00
Cal Corum
10983138a9 ci: Use docker-tags composite action for multi-channel release support
All checks were successful
Build Docker Image / build (push) Successful in 3m9s
Adds next-release branch trigger and replaces separate dev/production
build steps with the shared docker-tags action for tag resolution.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 15:40:06 -06:00
Cal Corum
44b6222ad5 fix: refactor Roster from 26 FK columns to RosterSlot junction table (#29)
- Remove card_1..card_26 FK columns from Roster ORM model
- Add RosterSlot model with (roster, slot, card) and a unique index on (roster, slot)
- Activate get_cards() helper on Roster using the new junction table
- Register RosterSlot in create_tables for SQLite dev environments
- Add migrations/migrate_roster_junction_table.py to backfill existing data

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 15:34:39 -06:00
Cal Corum
7b494faa99 fix: remove broken live_update_batting stub endpoint (#10)
The endpoint iterated over `files.vl_basic` (a string, not parsed CSV),
causing it to loop over individual characters. The body contained only
`pass` with TODO comments and no running stats logic. Removed the
endpoint entirely along with the dead commented-out csv helper code.
The `BattingFiles` model is retained as it is still used by
`live_update_pitching`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 15:34:06 -06:00
Cal Corum
0c042165b7 fix: replace broad except Exception blocks with DoesNotExist (#15)
Replace 71 broad `except Exception` blocks in 19 router files with the
specific `peewee.DoesNotExist` exception. GET endpoints that call
`Model.get_by_id()` now only catch the expected DoesNotExist error,
allowing real DB failures (connection errors, etc.) to propagate as
500s rather than being masked as 404s.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 15:32:53 -06:00
Cal Corum
62b205bde2 fix: batch BattingCard/BattingCardRatings lookups in lineup builder (#18)
Replace per-player get_or_none() calls in get_bratings() with two bulk
SELECT queries before the position loop, keyed by player_id and card+hand.
This reduces DB round trips from O(3N) to O(2) for all lineup difficulties.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 15:31:13 -06:00
cal
8227b57875 Merge pull request 'feat: add scout opportunities and claims API (#44)' (#59) from feat/scout-opportunities-claims into next-release
Reviewed-on: #59
2026-03-05 03:45:57 +00:00
Cal Corum
37439626ed chore: add PostgreSQL migration for scout tables (#44)
Creates scout_opportunity and scout_claim tables with foreign keys,
unique constraint on (opportunity, team), and expires_at index.
Already applied to dev database.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 03:45:38 +00:00
Cal Corum
5e182bedac feat: add scout_opportunities and scout_claims tables and API endpoints (#44)
Support the Discord bot's new scouting feature where players can scout
cards from other teams' opened packs. Stores opportunities with expiry
timestamps and tracks which teams claim which cards.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 03:45:38 +00:00
cal
9711f63da5 Merge pull request 'fix: use constant-time comparison for bearer token validation (#8)' (#56) from ai/paper-dynasty-database#8 into next-release
Reviewed-on: #56
2026-03-05 03:44:13 +00:00
Cal Corum
19ac5ffd0a fix: use constant-time comparison for bearer token validation (#8)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-05 03:43:59 +00:00
cal
551fccd9f2 Merge pull request 'fix: remove plaintext bearer token from warning logs (#7)' (#55) from ai/paper-dynasty-database#7 into next-release
Reviewed-on: #55
2026-03-05 03:43:40 +00:00
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