Commit Graph

256 Commits

Author SHA1 Message Date
Cal Corum
6637f6e9eb fix: disable autoconnect and set pool timeout on PooledPostgresqlDatabase (#80)
- Set timeout=5 so pool exhaustion surfaces as an error instead of hanging forever
- Set autoconnect=False to require explicit connection acquisition
- Add HTTP middleware in main.py to open/close connections per request

Closes #80

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 22:54:27 -05:00
cal
fa176c9b05 Merge pull request 'fix: enforce Literal validation on sort parameter in GET /api/v3/players (#66)' (#68) from ai/major-domo-database-66 into main 2026-04-08 03:54:02 +00:00
Cal Corum
ece25ec22c fix: enforce Literal validation on sort parameter in GET /api/v3/players (#66)
Closes #66

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 22:53:33 -05:00
cal
580e8ea031 Merge pull request 'fix: align CustomCommandCreator.discord_id model with BIGINT column (#78)' (#88) from issue/78-fix-discord-id-type-mismatch-between-model-charfie into main 2026-04-08 03:49:26 +00:00
Cal Corum
18394aa74e fix: align CustomCommandCreator.discord_id model with BIGINT column (#78)
Closes #78

Change CharField(max_length=20) to BigIntegerField to match the BIGINT
column created by the migration. Remove the str() workaround in
get_creator_by_discord_id() that was compensating for the type mismatch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 22:48:55 -05:00
cal
8e7466abd7 Merge pull request 'fix: remove token value from Bad Token log warnings (#79)' (#85) from issue/79-stop-logging-raw-auth-tokens-in-warning-messages into main 2026-04-08 03:43:13 +00:00
Cal Corum
d61bc31daa fix: remove token value from Bad Token log warnings (#79)
Closes #79

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 22:42:49 -05:00
cal
ca15dfe380 Merge pull request 'fix: replace row-by-row DELETE with bulk DELETE in career recalculation (#77)' (#92) from issue/77-replace-row-by-row-delete-with-bulk-delete-in-care into main 2026-04-08 03:24:58 +00:00
cal
1575be8260 Merge pull request 'fix: update Docker base image from Python 3.11 to 3.12 (#82)' (#91) from issue/82-align-python-version-between-docker-image-3-11-and into main 2026-04-08 03:24:46 +00:00
cal
7c7405cd1d Merge pull request 'feat: add migration tracking system (#81)' (#96) from issue/81-add-migration-tracking-system into main 2026-04-08 03:23:41 +00:00
cal
0cc0cba6a9 Merge pull request 'fix: replace deprecated Pydantic .dict() with .model_dump() (#76)' (#90) from issue/76-replace-deprecated-pydantic-dict-with-model-dump into main 2026-04-08 03:23:30 +00:00
cal
41fe4f6ce2 Merge pull request 'fix: add type annotations to untyped query parameters (#73)' (#86) from issue/73-add-type-annotations-to-untyped-query-parameters into main 2026-04-08 03:22:17 +00:00
cal
14234385fe Merge pull request 'fix: add combined_season classmethod to PitchingStat (#65)' (#67) from ai/major-domo-database-65 into main 2026-04-08 03:22:15 +00:00
cal
07aeaa8f3e Merge pull request 'fix: replace manual db.close() calls with middleware-based connection management (#71)' (#97) from issue/71-refactor-manual-db-close-calls-to-middleware-based into main 2026-04-08 02:42:09 +00:00
Cal Corum
701f790868 ci: retrigger build after transient Docker Hub push failure 2026-04-07 21:30:36 -05:00
Cal Corum
b46d8d33ef fix: remove empty finally clauses in custom_commands and help_commands
After removing db.close() calls, 22 finally: blocks were left empty
(12 in custom_commands.py, 10 in help_commands.py), causing
IndentationError at import time. Removed the finally: clause entirely
since connection lifecycle is now handled by the middleware.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 21:30:36 -05:00
Cal Corum
cfa6da06b7 fix: replace manual db.close() calls with middleware-based connection management (#71)
Closes #71

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 21:30:36 -05:00
cal
40897f1cc8 Merge pull request 'fix: move hardcoded Discord webhook URL to env var' (#83) from fix/remove-hardcoded-webhook into main
Reviewed-on: #83
Reviewed-by: Claude <cal.corum+openclaw@gmail.com>
2026-04-08 02:28:20 +00:00
12a76c2bb5 Merge branch 'main' into fix/remove-hardcoded-webhook 2026-04-08 02:24:10 +00:00
cal
aac4bf50d5 Merge pull request 'chore: switch CI to tag-triggered builds' (#107) from chore/tag-triggered-ci into main
Reviewed-on: #107
2026-04-06 16:59:02 +00:00
Cal Corum
4ad445b0da chore: switch CI to tag-triggered builds
Match the discord bot's CI pattern — trigger on CalVer tag push
instead of branch push/PR. Removes auto-CalVer generation and
simplifies to a single build step.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 16:58:45 +00:00
cal
8d9bbdd7a0 Merge pull request 'fix: increase get_games limit to 1000' (#106) from fix/increase-get-game-limit into main
All checks were successful
Build Docker Image / build (push) Successful in 1m6s
Reviewed-on: #106
2026-04-06 15:30:47 +00:00
cal
c95459fa5d Update app/routers_v3/stratgame.py
All checks were successful
Build Docker Image / build (pull_request) Successful in 4m51s
2026-04-06 14:58:36 +00:00
cal
d809590f0e Merge pull request 'fix: correct column references in season pitching stats SQL' (#105) from fix/pitching-stats-column-name into main
All checks were successful
Build Docker Image / build (push) Successful in 2m11s
2026-04-02 16:57:30 +00:00
cal
0d8e666a75 Merge pull request 'fix: let HTTPException pass through @handle_db_errors' (#104) from fix/handle-db-errors-passthrough-http into main
Some checks failed
Build Docker Image / build (push) Has been cancelled
2026-04-02 16:57:12 +00:00
Cal Corum
bd19b7d913 fix: correct column references in season pitching stats view
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m4s
sp.on_first/on_second/on_third don't exist — the actual columns are
on_first_id/on_second_id/on_third_id. This caused failures when
updating season pitching stats after games.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:54:56 -05:00
Cal Corum
c49f91cc19 test: update test_get_nonexistent_play to expect 404 after HTTPException fix
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m3s
After handle_db_errors no longer catches HTTPException, GET /plays/999999999
correctly returns 404 instead of 500. Update the assertion and docstring
to reflect the fixed behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02 09:30:39 -05:00
Cal Corum
215085b326 fix: let HTTPException pass through @handle_db_errors unchanged
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m34s
The decorator was catching all exceptions including intentional
HTTPException (401, 404, etc.) and re-wrapping them as 500 "Database
error". This masked auth failures and other deliberate HTTP errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 08:30:22 -05:00
cal
c063f5c4ef Merge pull request 'hotfix: remove output caps from GET /players' (#103) from hotfix/remove-players-output-caps into main
All checks were successful
Build Docker Image / build (push) Successful in 1m3s
2026-04-02 01:19:51 +00:00
Cal Corum
d92f571960 hotfix: remove output caps from GET /players endpoint
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m29s
The MAX_LIMIT/DEFAULT_LIMIT caps added in 16f3f8d are too restrictive
for the /players endpoint — bot and website consumers need full player
lists without pagination. Reverts limit param to Optional[int] with no
ceiling while keeping caps on all other endpoints.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 20:14:35 -05:00
cal
81baa54681 Merge pull request 'Fix unbounded API queries causing worker timeouts' (#99) from bugfix/limit-caps into main
All checks were successful
Build Docker Image / build (push) Successful in 1m9s
Reviewed-on: #99
2026-04-01 22:44:38 +00:00
Cal Corum
67e87a893a Fix fieldingstats count computed after limit applied
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m9s
Capture total_count before .limit() so the response count reflects
all matching rows, not just the capped page size. Resolves #100.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 17:40:02 -05:00
Cal Corum
16f3f8d8de Fix unbounded API queries causing Gunicorn worker timeouts
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m32s
Add MAX_LIMIT=500 cap across all list endpoints, empty string
stripping middleware, and limit/offset to /transactions. Resolves #98.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 17:23:25 -05:00
Cal Corum
b35b68a88f Merge remote-tracking branch 'origin/main' into fix/remove-hardcoded-webhook
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m58s
2026-03-28 02:27:14 -05:00
cal
a1fa54c416 Merge pull request 'fix: remove hardcoded fallback password from DB connection' (#84) from fix/remove-default-db-password into main
All checks were successful
Build Docker Image / build (push) Successful in 2m46s
2026-03-28 07:26:55 +00:00
Cal Corum
eccf4d1441 feat: add migration tracking system (#81)
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m11s
Adds schema_versions table and migrations.py runner to prevent
double-application and missed migrations across dev/prod environments.

- migrations/2026-03-27_add_schema_versions_table.sql: creates tracking table
- migrations.py: applies pending .sql files in sorted order, records each in schema_versions
- .gitignore: untrack migrations.py (was incorrectly ignored as legacy root file)

First run on an existing DB will apply all migrations (safe — all use IF NOT EXISTS).

Closes #81

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 05:34:13 -05:00
Cal Corum
d8c6ce2a5e fix: replace row-by-row DELETE with bulk DELETE in career recalculation (#77)
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m4s
Closes #77

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 03:02:55 -05:00
Cal Corum
665f275546 fix: update Docker base image from Python 3.11 to 3.12 (#82)
Some checks failed
Build Docker Image / build (pull_request) Failing after 49s
Closes #82

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 02:32:01 -05:00
Cal Corum
75a8fc8505 fix: replace deprecated Pydantic .dict() with .model_dump() (#76)
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m26s
Closes #76

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 02:02:49 -05:00
Cal Corum
dcaf184ad3 fix: add type annotations to untyped query parameters (#73)
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m11s
Closes #73

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 00:02:57 -05:00
Cal Corum
1bcde424c6 Address PR review feedback for DISCORD_WEBHOOK_URL env var
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m32s
- Add DISCORD_WEBHOOK_URL to docker-compose.yml api service environment block
- Add empty placeholder entry in .env for discoverability
- Move DISCORD_WEBHOOK_URL constant to the env-var constants section at top of dependencies.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 23:23:26 -05:00
Cal Corum
3be4f71e22 fix: move hardcoded Discord webhook URL to environment variable
All checks were successful
Build Docker Image / build (pull_request) Successful in 3m42s
Replace inline webhook URL+token with DISCORD_WEBHOOK_URL env var.
Logs a warning and returns False gracefully if the var is unset.

The exposed webhook token should be rotated in Discord.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 23:15:21 -05:00
Cal Corum
c451e02c52 fix: remove hardcoded fallback password from PostgreSQL connection
All checks were successful
Build Docker Image / build (pull_request) Successful in 18m25s
Raise RuntimeError on startup if POSTGRES_PASSWORD env var is not set,
instead of silently falling back to a known password in source code.

Closes #C2 from postgres migration review.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 23:15:07 -05:00
Cal Corum
a21bb2a380 fix: add combined_season classmethod to PitchingStat (#65)
All checks were successful
Build Docker Image / build (pull_request) Successful in 2m17s
Closes #65

`PitchingStat.combined_season()` was referenced in the `get_pitstats`
handler but never defined, causing a 500 on `s_type=combined/total/all`.

Added `combined_season` as a `@staticmethod` matching the pattern of
`BattingStat.combined_season` — returns all rows for the given season
with no week filter (both regular and postseason).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 17:33:47 -05:00
cal
da679b6d1a Merge pull request 'Release: merge next-release into main' (#64) from next-release into main
All checks were successful
Build Docker Image / build (push) Successful in 1m6s
Reviewed-on: #64
2026-03-17 21:43:36 +00:00
Cal Corum
697152808b fix: validate sort_by parameter with Literal type in views.py (#36)
All checks were successful
Build Docker Image / build (pull_request) Successful in 4m13s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 16:29:58 -05:00
Cal Corum
c40426d175 fix: remove unimplementable skipped caching tests (#33)
The three skipped tests in TestPlayerServiceCache required caching
in get_players() (read-through cache) and cache propagation through
the cls() pattern in write methods — neither is implemented and the
architecture does not support it without significant refactoring.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 16:29:58 -05:00
Cal Corum
95ff5eeaf9 fix: replace print(req.scope) with logger.debug in /api/docs (#21)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 16:29:58 -05:00
Cal Corum
a0d5d49724 fix: address review feedback (#52)
Guard bulk ID queries against empty lists to prevent PostgreSQL
syntax error (WHERE id IN ()) when batch POST endpoints receive
empty request bodies.

Affected endpoints:
- POST /api/v3/transactions
- POST /api/v3/results
- POST /api/v3/schedules
- POST /api/v3/battingstats

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 16:29:58 -05:00
Cal Corum
b0fd1d89ea fix: eliminate N+1 queries in batch POST endpoints (#25)
Replace per-row Team/Player lookups with bulk IN-list queries before
the validation loop in post_transactions, post_results, post_schedules,
and post_batstats. A 50-move batch now uses 2 queries instead of 150.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-17 16:29:58 -05:00