feat: add coach_name, team_id, height to AccountPlayerResponse #288

Merged
forgejo_admin merged 1 commit from 282-parent-dashboard-enrichment into main 2026-04-03 22:26:57 +00:00

Summary

Enriches the parent dashboard /account/players endpoint with coach_name, team_id, and height fields so parents can see their child's coach, team identifier, and height without missing data.

Changes

  • src/basketball_api/routes/account.py -- Added team_id: Optional[int], coach_name: Optional[str], height: Optional[str] to AccountPlayerResponse. Updated query to eagerly load Team.coach via subqueryload+joinedload. Populated new fields from player's team/coach/profile relationships.
  • tests/test_account.py -- Added sample_coach fixture with team assignment. Added test_includes_coach_name_and_team_id (verifies assigned vs unassigned players). Added test_includes_height (verifies height present/null). Updated test_response_fields to assert new fields.

Test Plan

  • All 9 account tests pass (6 existing + 3 new)
  • ruff format and ruff check clean
  • Full suite: 615 passed; pre-existing failures in tryouts/teams/token_store unrelated to this change

Review Checklist

  • Implementation complete
  • Tests written and passing
  • ruff format and ruff check clean
  • No discovered scope
  • None
  • Forgejo issue: #282
  • Spike: #278 (Mismatch 3)

Closes #282

## Summary Enriches the parent dashboard `/account/players` endpoint with `coach_name`, `team_id`, and `height` fields so parents can see their child's coach, team identifier, and height without missing data. ## Changes - `src/basketball_api/routes/account.py` -- Added `team_id: Optional[int]`, `coach_name: Optional[str]`, `height: Optional[str]` to `AccountPlayerResponse`. Updated query to eagerly load `Team.coach` via `subqueryload`+`joinedload`. Populated new fields from player's team/coach/profile relationships. - `tests/test_account.py` -- Added `sample_coach` fixture with team assignment. Added `test_includes_coach_name_and_team_id` (verifies assigned vs unassigned players). Added `test_includes_height` (verifies height present/null). Updated `test_response_fields` to assert new fields. ## Test Plan - All 9 account tests pass (6 existing + 3 new) - `ruff format` and `ruff check` clean - Full suite: 615 passed; pre-existing failures in tryouts/teams/token_store unrelated to this change ## Review Checklist - [x] Implementation complete - [x] Tests written and passing - [x] `ruff format` and `ruff check` clean - [x] No discovered scope ## Related Notes - None ## Related - Forgejo issue: #282 - Spike: #278 (Mismatch 3) Closes #282
feat: add coach_name, team_id, height to AccountPlayerResponse
Some checks failed
ci/woodpecker/pr/woodpecker Pipeline failed
85477931eb
Parents need to see their child's coach, team identifier, and height
on the dashboard. Enriches the /account/players endpoint with these
fields populated from player team/coach relationships.

Closes #282

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner

QA Review -- PR #288

Summary

Adds coach_name, team_id, and height to AccountPlayerResponse for the parent dashboard endpoint. Clean, focused change across 2 files.

Findings

Route (account.py)

  • Three new Optional fields on the Pydantic model -- correct typing, correct placement.
  • Query updated from joinedload(Player.teams) to subqueryload(Player.teams).joinedload(Team.coach) -- avoids N+1 on coach lookup. Good.
  • Null-safe field population: team.coach.name if team and team.coach else None -- handles unassigned players and teams without coaches.
  • player.height is a direct column read -- no relationship traversal needed.
  • Unused import: subqueryload and Team are both used. No dead imports.

Tests (test_account.py)

  • New sample_coach fixture with CoachRole.head_coach -- correct enum value.
  • sample_team updated to depend on sample_coach via coach_id -- existing tests still pass since the coach is now always seeded.
  • height="5'11\"" set on player1; player2 has no height -- covers both branches.
  • test_includes_coach_name_and_team_id: asserts assigned player gets coach name + team_id, unassigned gets null for both.
  • test_includes_height: asserts height present vs null.
  • test_response_fields: updated to include the 3 new field assertions.

SOP Compliance

  • ruff format and ruff check clean
  • Branch naming: 282-parent-dashboard-enrichment follows {issue}-{slug} convention
  • PR body has Closes #282
  • All acceptance criteria from #282 met

Nits

None.

VERDICT: APPROVED

## QA Review -- PR #288 ### Summary Adds `coach_name`, `team_id`, and `height` to `AccountPlayerResponse` for the parent dashboard endpoint. Clean, focused change across 2 files. ### Findings **Route (`account.py`)** - Three new `Optional` fields on the Pydantic model -- correct typing, correct placement. - Query updated from `joinedload(Player.teams)` to `subqueryload(Player.teams).joinedload(Team.coach)` -- avoids N+1 on coach lookup. Good. - Null-safe field population: `team.coach.name if team and team.coach else None` -- handles unassigned players and teams without coaches. - `player.height` is a direct column read -- no relationship traversal needed. - Unused import: `subqueryload` and `Team` are both used. No dead imports. **Tests (`test_account.py`)** - New `sample_coach` fixture with `CoachRole.head_coach` -- correct enum value. - `sample_team` updated to depend on `sample_coach` via `coach_id` -- existing tests still pass since the coach is now always seeded. - `height="5'11\""` set on player1; player2 has no height -- covers both branches. - `test_includes_coach_name_and_team_id`: asserts assigned player gets coach name + team_id, unassigned gets null for both. - `test_includes_height`: asserts height present vs null. - `test_response_fields`: updated to include the 3 new field assertions. **SOP Compliance** - [x] `ruff format` and `ruff check` clean - [x] Branch naming: `282-parent-dashboard-enrichment` follows `{issue}-{slug}` convention - [x] PR body has `Closes #282` - [x] All acceptance criteria from #282 met ### Nits None. **VERDICT: APPROVED**
forgejo_admin deleted branch 282-parent-dashboard-enrichment 2026-04-03 22:26:57 +00:00
Sign in to join this conversation.
No description provided.