feat: add get_away_team and get_home_team methods to StratGame (#21) #67

Closed
cal wants to merge 13 commits from ai/paper-dynasty-discord-21 into main
Owner

Summary

  • Adds get_away_team() and get_home_team() async methods to the StratGame dataclass
  • Both delegate to the existing get_game_team() function, which already handles the SBA vs PD distinction
  • Removes the # TODO comment from the Game ORM class that requested these methods

What was fixed

Callers that needed to look up a team from a StratGame had to repeat the inline logic (checking game.is_pd, calling get_pd_team vs get_sba_team). These methods centralize that pattern on the dataclass itself.

Usage

away = await game.get_away_team()
home = await game.get_home_team()
# optional: skip_cache=True to force a fresh fetch

Files changed

  • db_calls_gameplay.py — Added two methods to StratGame; removed the TODO comment from Game

Other observations

  • Ruff auto-formatter (project hook) applied cosmetic quote-style changes ('") throughout the file, consistent with all prior PRs in this repo. Functional diff is the two new methods + TODO removal only.

🤖 Generated with Claude Code

## Summary - Adds `get_away_team()` and `get_home_team()` async methods to the `StratGame` dataclass - Both delegate to the existing `get_game_team()` function, which already handles the SBA vs PD distinction - Removes the `# TODO` comment from the `Game` ORM class that requested these methods ## What was fixed Callers that needed to look up a team from a `StratGame` had to repeat the inline logic (checking `game.is_pd`, calling `get_pd_team` vs `get_sba_team`). These methods centralize that pattern on the dataclass itself. ## Usage ```python away = await game.get_away_team() home = await game.get_home_team() # optional: skip_cache=True to force a fresh fetch ``` ## Files changed - `db_calls_gameplay.py` — Added two methods to `StratGame`; removed the TODO comment from `Game` ## Other observations - Ruff auto-formatter (project hook) applied cosmetic quote-style changes (`'` → `"`) throughout the file, consistent with all prior PRs in this repo. Functional diff is the two new methods + TODO removal only. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
cal added 1 commit 2026-03-05 15:34:19 +00:00
feat: add get_away_team and get_home_team methods to StratGame (#21)
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m14s
1d79657fa1
Implements the TODO at db_calls_gameplay.py:190. Both async methods
delegate to get_game_team(), which already handles the SBA vs PD
distinction, returning the appropriate Team dict without callers
needing to repeat the lookup logic inline.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
cal added the
ai-reviewing
label 2026-03-05 15:45:33 +00:00
cal reviewed 2026-03-05 15:47:44 +00:00
cal left a comment
Author
Owner

AI Code Review

Files Reviewed

  • db_calls_gameplay.py (modified)

Findings

Correctness

  • StratGame has away_team_id: int and home_team_id: int as required fields — both methods reference them correctly.
  • get_game_team signature is (game: StratGame, gm_id=None, team_abbrev=None, team_id=None, skip_cache=False) -> dict. The new methods call it as get_game_team(self, team_id=self.away/home_team_id, skip_cache=skip_cache) — fully correct.
  • get_game_team is defined after StratGame in the file (~line 291 vs ~line 193). This is a forward reference in a method body, which Python resolves at call time (not class definition time). No issue.
  • Both methods are correctly async since get_game_team is async.
  • Return type annotation -> dict matches get_game_team's return type. ✓
  • skip_cache is correctly passed through. ✓
  • TODO removal from Game is correct — the requested functionality is now implemented. Placement on StratGame (the runtime dataclass) rather than Game (the Peewee ORM model) is actually the right call, since callers work with StratGame instances.

Security

  • No issues. Pure internal delegation with no external input.

Style & Conventions

  • Methods follow project async patterns and use the existing get_game_team abstraction correctly.
  • Ruff quote normalization ('") throughout the file is cosmetic only, consistent with PRs #58–#66.

Suggestions

  • No blocking suggestions. A thin test exercising get_away_team/get_home_team against a mock get_game_team would be nice, but not required for a one-line delegation wrapper.

Verdict: APPROVED

Clean, correct implementation. The delegation to get_game_team centralizes SBA/PD team-lookup logic as intended. No edge cases, no security concerns, follows project conventions.


Automated review by Claude PR Reviewer

## AI Code Review ### Files Reviewed - `db_calls_gameplay.py` (modified) ### Findings #### Correctness - `StratGame` has `away_team_id: int` and `home_team_id: int` as required fields — both methods reference them correctly. - `get_game_team` signature is `(game: StratGame, gm_id=None, team_abbrev=None, team_id=None, skip_cache=False) -> dict`. The new methods call it as `get_game_team(self, team_id=self.away/home_team_id, skip_cache=skip_cache)` — fully correct. - `get_game_team` is defined after `StratGame` in the file (~line 291 vs ~line 193). This is a forward reference in a method body, which Python resolves at call time (not class definition time). No issue. - Both methods are correctly `async` since `get_game_team` is `async`. - Return type annotation `-> dict` matches `get_game_team`'s return type. ✓ - `skip_cache` is correctly passed through. ✓ - TODO removal from `Game` is correct — the requested functionality is now implemented. Placement on `StratGame` (the runtime dataclass) rather than `Game` (the Peewee ORM model) is actually the right call, since callers work with `StratGame` instances. #### Security - No issues. Pure internal delegation with no external input. #### Style & Conventions - Methods follow project async patterns and use the existing `get_game_team` abstraction correctly. - Ruff quote normalization (`'` → `"`) throughout the file is cosmetic only, consistent with PRs #58–#66. #### Suggestions - No blocking suggestions. A thin test exercising `get_away_team`/`get_home_team` against a mock `get_game_team` would be nice, but not required for a one-line delegation wrapper. ### Verdict: APPROVED Clean, correct implementation. The delegation to `get_game_team` centralizes SBA/PD team-lookup logic as intended. No edge cases, no security concerns, follows project conventions. --- *Automated review by Claude PR Reviewer*
cal added
ai-reviewed
and removed
ai-reviewing
labels 2026-03-05 15:48:10 +00:00
cal changed target branch from main to next-release 2026-03-07 07:32:47 +00:00
cal force-pushed ai/paper-dynasty-discord-21 from 1d79657fa1 to 109b88b9e5 2026-03-07 07:33:31 +00:00 Compare
cal changed target branch from next-release to main 2026-03-23 04:14:29 +00:00
Author
Owner

Closing — will re-implement fresh against main. Original PR had unrebaseable conflicts from the scouting refactor.

Closing — will re-implement fresh against `main`. Original PR had unrebaseable conflicts from the scouting refactor.
cal closed this pull request 2026-03-23 04:15:39 +00:00

Pull request closed

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/paper-dynasty-discord#67
No description provided.