Release: merge next-release into main #64

Merged
cal merged 11 commits from next-release into main 2026-03-17 21:43:38 +00:00
Owner

Summary

11 commits from next-release rebased onto main and ready to ship.

  • perf: Push limit/offset to DB in PlayerService.get_players (#37)
  • fix: Invalidate cache after PlayerService write operations (#32)
  • fix: Remove empty WEEK_NUMS dict from db_engine.py (#34)
  • fix: Validate sort_by parameter with Literal type in views.py (#36)
  • fix: Replace print(req.scope) with logger.debug in /api/docs (#21)
  • fix: Remove unused imports in standings.py and pitchingstats.py (#30)
  • fix: Replace bare except: with except Exception: (#29)
  • fix: Eliminate N+1 queries in batch POST endpoints (#25)
  • fix: Calculate lob_2outs and rbipercent in SeasonPitchingStats (#28)
  • fix: Remove unimplementable skipped caching tests (#33)

Conflict resolution

Rebased (not squash-merged) to surface conflicts cleanly. Resolved:

  • 6 router files (battingstats, results, schedules, transactions, pitchingstats, custom_commands): kept main's @router.post("/") trailing slash fix; applied next-release's functional changes on top
  • transactions.py: preserved fn.UPPER(Team.abbrev) case-insensitive filter from main
  • requirements.txt: kept main's fully-pinned deps including starlette==0.52.1
  • standings.py: took next-release's import block (pydantic import removed, genuinely unused)

Test plan

  • Deploy to staging and smoke-test batch POST endpoints (battingstats, results, schedules, transactions)
  • Verify team_abbrev filter on transactions still works case-insensitively
  • Verify player list pagination (limit/offset) works correctly
  • Confirm no bare except: blocks remain: grep -r "except:" app/
## Summary 11 commits from `next-release` rebased onto `main` and ready to ship. - **perf:** Push `limit`/`offset` to DB in `PlayerService.get_players` (#37) - **fix:** Invalidate cache after `PlayerService` write operations (#32) - **fix:** Remove empty `WEEK_NUMS` dict from `db_engine.py` (#34) - **fix:** Validate `sort_by` parameter with `Literal` type in `views.py` (#36) - **fix:** Replace `print(req.scope)` with `logger.debug` in `/api/docs` (#21) - **fix:** Remove unused imports in `standings.py` and `pitchingstats.py` (#30) - **fix:** Replace bare `except:` with `except Exception:` (#29) - **fix:** Eliminate N+1 queries in batch POST endpoints (#25) - **fix:** Calculate `lob_2outs` and `rbipercent` in `SeasonPitchingStats` (#28) - **fix:** Remove unimplementable skipped caching tests (#33) ## Conflict resolution Rebased (not squash-merged) to surface conflicts cleanly. Resolved: - **6 router files** (`battingstats`, `results`, `schedules`, `transactions`, `pitchingstats`, `custom_commands`): kept main's `@router.post("/")` trailing slash fix; applied next-release's functional changes on top - **`transactions.py`**: preserved `fn.UPPER(Team.abbrev)` case-insensitive filter from main - **`requirements.txt`**: kept main's fully-pinned deps including `starlette==0.52.1` - **`standings.py`**: took next-release's import block (pydantic import removed, genuinely unused) ## Test plan - [ ] Deploy to staging and smoke-test batch POST endpoints (battingstats, results, schedules, transactions) - [ ] Verify `team_abbrev` filter on transactions still works case-insensitively - [ ] Verify player list pagination (`limit`/`offset`) works correctly - [ ] Confirm no bare `except:` blocks remain: `grep -r "except:" app/`
cal added 11 commits 2026-03-17 21:33:23 +00:00
Both fields were hardcoded to 0.0 in the INSERT. Added SQL expressions
to the pitching_stats CTE to calculate them from stratplay data, using
the same logic as the batting stats endpoint.

- lob_2outs: count of runners stranded when pitcher recorded the 3rd out
- rbipercent: RBI allowed (excluding HR) per runner opportunity

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Apply .offset() and .limit() on the Peewee query before materializing
results, instead of fetching all rows into memory and slicing in Python.
Total count is obtained via query.count() before pagination is applied.
In-memory (mock) queries continue to use Python-level slicing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Dead code - module-level constant defined but never referenced.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add finally blocks to update_player, patch_player, create_players, and
delete_player in PlayerService to call invalidate_related_cache() using
the existing cache_patterns. Matches the pattern already used in
TeamService.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
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>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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>
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
697152808b
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cal merged commit da679b6d1a into main 2026-03-17 21:43:38 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cal/major-domo-database#64
No description provided.