Commit Graph

258 Commits

Author SHA1 Message Date
cal
84a45d9caa fix: use mode=min for Docker build cache to avoid Hub blob limits
Some checks failed
Build Docker Image / build (push) Failing after 8m12s
mode=max pushes all intermediate layers to Docker Hub as cache, which
exceeds blob size limits when the base image changes. mode=min only
caches final image layers — smaller push, still provides cache hits
for the most common rebuild scenario (code changes, same base).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 17:02:15 +00:00
cal
47dcdf00c4 fix: switch to python:3.11-slim-bookworm base image
Some checks failed
Build Docker Image / build (push) Failing after 8m12s
The tiangolo/uvicorn-gunicorn-fastapi image moved to Debian Trixie
(testing) which Playwright doesn't support — install-deps fails on
renamed font packages. The tiangolo image only adds uvicorn/gunicorn
which are already in requirements.txt, so switch to the official Python
slim-bookworm image directly. Also removes the old commented-out Chrome
manual install block that hasn't been used since the Playwright migration.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 16:42:51 +00:00
cal
a6cf4eea01 fix: pin base image to Debian Bookworm for Playwright compatibility
Some checks failed
Build Docker Image / build (push) Failing after 57s
The tiangolo base image recently moved to Debian Trixie (testing), which
Playwright doesn't support yet. `playwright install-deps` fails because
ttf-unifont and ttf-ubuntu-font-family packages were renamed/removed in
Trixie. Pinning to slim-bookworm (Debian 12) restores compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 16:40:04 +00:00
cal
569dc07864 Merge pull request 'feat: persistent browser instance for card rendering (#89)' (#97) from ai/paper-dynasty-database#89 into next-release
Some checks failed
Build Docker Image / build (push) Failing after 4m50s
Reviewed-on: #97
2026-03-16 16:21:29 +00:00
Cal Corum
f471354e39 feat: persistent browser instance for card rendering (#89)
Replace per-request Chromium launch/teardown with a module-level
persistent browser. get_browser() lazy-initializes with is_connected()
auto-reconnect; shutdown_browser() is wired into FastAPI lifespan for
clean teardown. Pages are created per-request and closed in a finally
block to prevent leaks.

Also fixed pre-existing ruff errors in staged files (E402 noqa comments,
F541 f-string prefix removal, F841 unused variable rename) that were
blocking the pre-commit hook.

Closes #89

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-16 11:20:42 -05:00
cal
32ca21558e Merge pull request 'feat: Track Catalog API endpoints (WP-06) (#71)' (#86) from ai/paper-dynasty-database#71 into next-release
Some checks failed
Build Docker Image / build (push) Failing after 4m43s
Reviewed-on: #86
2026-03-16 16:14:58 +00:00
cal
01c8aa140c Merge pull request 'feat: PlayerSeasonStats Peewee model (#67)' (#82) from ai/paper-dynasty-database#67 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #82
2026-03-16 16:13:06 +00:00
cal
223743d89f Merge pull request 'feat: evolution track seed data and tests (WP-03) (#68)' (#83) from ai/paper-dynasty-database#68 into next-release
Some checks are pending
Build Docker Image / build (push) Waiting to run
Reviewed-on: #83
2026-03-16 16:12:18 +00:00
cal
44763a07ec Merge pull request 'feat: formula engine for evolution value computation (WP-09) (#74)' (#85) from ai/paper-dynasty-database#74 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #85
2026-03-16 16:10:42 +00:00
cal
8d0111df32 Merge pull request 'fix: batch Paperdex lookups to avoid N+1 queries (#17)' (#53) from ai/paper-dynasty-database#17 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #53
Reviewed-by: Claude <cal.corum+openclaw@gmail.com>
2026-03-16 16:09:54 +00:00
cal
8a437c7ef3 Merge pull request 'fix: remove stub live_update_pitching endpoint (#11)' (#57) from ai/paper-dynasty-database#11 into next-release
Some checks failed
Build Docker Image / build (push) Has been cancelled
Reviewed-on: #57
Reviewed-by: Claude <cal.corum+openclaw@gmail.com>
2026-03-16 16:09:13 +00:00
Cal Corum
ddf6ff5961 feat: Track Catalog API endpoints (WP-06) (#71)
Closes #71

Adds GET /api/v2/evolution/tracks and GET /api/v2/evolution/tracks/{track_id}
endpoints for browsing evolution tracks and their thresholds.  Both endpoints
require Bearer token auth and return a track dict with formula and t1-t4
threshold fields.  The card_type query param filters the list endpoint.

EvolutionTrack is lazy-imported inside each handler so the app can start
before WP-01 (EvolutionTrack model) is merged into next-release.

Also suppresses pre-existing E402/F541 ruff warnings in app/main.py via
pyproject.toml per-file-ignores so the pre-commit hook does not block
unrelated future commits to that file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 20:40:38 -05:00
Cal Corum
40e988ac9d feat: formula engine for evolution value computation (WP-09)
Closes #74

Adds app/services/formula_engine.py with three pure formula functions
(compute_batter_value, compute_sp_value, compute_rp_value), a dispatch
helper (compute_value_for_track), and a tier classifier (tier_from_value).
Tier boundaries and thresholds match the locked seed data from WP-03.

Note: pitcher formulas use stats.k (not stats.so) to match the
PlayerSeasonStats model field name introduced in WP-02.

19 unit tests in tests/test_formula_engine.py — all pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 19:34:40 -05:00
Cal Corum
25f04892c2 feat: evolution track seed data and tests (WP-03) (#68)
Closes #68

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 17:35:12 -05:00
Cal Corum
8dfc5ef371 fix: remove evolution models from WP-02 PR (#82)
Evolution models (EvolutionTrack, EvolutionCardState, EvolutionTierBoost,
EvolutionCosmetic), their re-export module, and tests were included in
this PR without disclosure. Removed to keep this PR scoped to
PlayerSeasonStats (WP-02) only per review feedback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 17:02:00 -05:00
Cal Corum
4bfd878486 feat: add PlayerSeasonStats Peewee model (#67)
Closes #67

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 16:35:02 -05:00
Cal Corum
4445acb7d0 fix: materialize final_players queryset before double-iteration in get_random_player
When no position filters are applied, `final_players` is a lazy Peewee queryset
with `ORDER BY RANDOM() LIMIT n`. Iterating it twice (once to build player_ids,
once for the response loop) executes two separate DB queries with different random
seeds, causing dex_by_player to be built for a different player set than returned,
silently producing empty paperdex for all players.

Add `final_players = list(final_players)` before building player_ids to ensure
both iterations operate on the same materialized result. Also fix pre-existing
syntax error in import statement and minor ruff lint issues in the same file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 14:03:26 -05:00
cal
a66ef9bd7c Merge pull request 'fix: use max() for pitcher OPS split weighting (#6)' (#60) from ai/paper-dynasty-database#6 into next-release
Some checks failed
Build Docker Image / build (push) Failing after 5m11s
Reviewed-on: #60
2026-03-10 14:42:59 +00:00
cal
6afb2773fe Merge pull request 'chore: pin all Python dependency versions in requirements.txt (#64)' (#65) from ai/paper-dynasty-database#64 into next-release
Some checks failed
Build Docker Image / build (push) Failing after 4m21s
Reviewed-on: #65
2026-03-10 14:06:40 +00:00
Cal Corum
f37217af25 chore: pin all Python dependency versions in requirements.txt (#64)
- Pin all 14 dependencies to exact versions (==)
- Remove duplicate python-multipart entry
- Upgrade numpy from floor constraint (<2) to exact pin (1.26.4, latest 1.x)
- Pin Dockerfile base image from :latest to :python3.11

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-10 01:35:31 -05:00
Cal Corum
7f139770d1 fix: remove stray syntax error in players.py db_engine import
Some checks failed
Build Docker Image / build (push) Failing after 6m28s
Build Docker Image / build (pull_request) Successful in 3m19s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 09:43:03 -05:00
Cal Corum
3b7bb2b6b5 fix: remove stray syntax error in teams.py db_engine import
All checks were successful
Build Docker Image / build (push) Successful in 49s
Build Docker Image / build (pull_request) Successful in 46s
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 14:36:41 +00:00
cal
7b8b7b9c01 Merge pull request 'Release: Scouting API, roster refactor, and bug fixes' (#61) from next-release into main
Some checks failed
Build Docker Image / build (push) Failing after 7m5s
Reviewed-on: #61
2026-03-09 14:12:41 +00:00
Cal Corum
4f2513ae8b fix: use max() for pitcher OPS split weighting (#6)
Starters face both LHH and RHH, so the OPS aggregation formula should
penalise the weaker platoon split (higher OPS allowed) rather than
reward the stronger one. Changed min(ops_vl, ops_vr) → max(ops_vl, ops_vr)
in both get_total_ops (line 621) and sort_starters (line 703) and
replaced the TODO comment with an explanatory note.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 16:32:56 -06:00
Cal Corum
c3732ef33e fix: remove stub live_update_pitching endpoint (#11)
The /live-update/pitching POST endpoint was a placeholder that only
validated auth and returned the input unchanged. No pitching processing
logic existed anywhere in the codebase. Removed the dead endpoint.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 01:37:52 -06:00
Cal Corum
2c4ff01ff8 fix: batch Paperdex lookups to avoid N+1 queries (#17)
Replace per-player/card Paperdex.select().where() calls with a single
batched query grouped by player_id. Eliminates N+1 queries in:
- players list endpoint (get_players, with inc_dex flag)
- players by team endpoint
- cards list endpoint (also materializes query to avoid double count())

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 01:37:03 -06:00
cal
7295e77c96 Merge pull request 'fix: refactor Roster from 26 FK columns to RosterSlot junction table (#29)' (#58) from ai/paper-dynasty-database#29 into next-release
Some checks failed
Build Docker Image / build (push) Successful in 3m28s
Build Docker Image / build (pull_request) Has been cancelled
Reviewed-on: #58
2026-03-07 03:23:41 +00:00
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