feat: add team_ids to AccountPlayerResponse (#333) #334
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ldraney/basketball-api!334
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "333-add-team-ids-account-response"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
team_ids: list[int]toAccountPlayerResponseso the parent dashboard can filter/public/scheduleby teamplayer.teamsM2M relationship (already eagerly loaded)team_namefield unchangedChanges
src/basketball_api/routes/account.py— 2 lines added (field + population)Test Plan
GET /account/playersresponse includesteam_idsReview Checklist
team_nameunchanged (backwards compatible)[]team_idsusage in admin route (line 713)Related Notes
story:WS-S28— parent schedule user storyarch-auth-westside-basketball— updated to include schedule viewing for parent roleCloses #333
PR #334 Review
DOMAIN REVIEW
Tech stack: Python / FastAPI / SQLAlchemy / Pydantic
This PR makes two separate changes:
1.
team_ids: list[int]added toAccountPlayerResponse(src/basketball_api/routes/account.py)[t.id for t in player.teams]-- matches the existing pattern used inTeamPlayerItematadmin.py:715Player.teamsM2M relationship useslazy="selectin"on the model, and the query already hasjoinedload(Player.teams)-- no N+1 riskteam_namefield unchanged -- backwards compatible[](empty list comprehension) -- correct2.
is_public: booladded toAdminPlayerItem(src/basketball_api/routes/admin.py)player.is_publicwhich exists on the Player model withserver_default=text("false")test_admin_spa.pyto assertis_publicin expected fieldsBoth changes are straightforward field enrichments to existing response models. The code quality is clean.
BLOCKERS
1. Missing test coverage for
team_idsin account routeThe
test_account.pyfile has 7 tests includingtest_response_fields(line 227-245) andtest_includes_team_name(line 169-181). Neither test is updated to verify the newteam_idsfield. Specifically:test_response_fieldschecks forid,name,status,team_name,subscription_status,division,position,graduating_class,photo_url-- but NOTteam_idstest_includes_team_nameassertsteam_namevalues for assigned/unassigned players but does not assertteam_idsteam_ids == [team.id]for assigned player) or the empty case (team_ids == []for unassigned player)New functionality with zero test coverage is a blocker per review criteria. The admin
is_publicchange has its test updated, but the headline feature (team_ids) does not.File:
/home/ldraney/basketball-api/tests/test_account.py--test_response_fieldsat line 227 andtest_includes_team_nameat line 169 need updates.NITS
Undisclosed scope: The PR title and summary describe only the
team_idsaddition toAccountPlayerResponse. Theis_publicaddition toAdminPlayerItemis not mentioned anywhere in the PR body. The Changes section says "2 lines added" but the diff shows 5 additions across 3 files. This should be documented in the PR body for traceability.Related section references: The Related section references
westside-landing#214andstory:WS-S28. Theis_publicadmin change presumably has its own motivation -- it should reference the related issue or story.SOP COMPLIANCE
333-add-team-ids-account-responsefollows{issue-number}-{kebab-case-purpose}conventionis_publicchangestory:WS-S28)is_publicaddition toAdminPlayerItemis unrelated to issue #333 (addingteam_idsto account response)PROCESS OBSERVATIONS
Small enrichment PRs like this have low change failure risk. The pattern is well-established in the codebase (identical list comprehension at
admin.py:715). The missing test is a mechanical fix -- addteam_idsassertions to the existingtest_response_fieldsandtest_includes_team_nametests, which already set up the right fixtures (one player assigned to a team, one not).The undisclosed
is_publicscope should either be documented in this PR or split to its own issue/PR for traceability. It is a one-liner with its test already updated, so documenting it here is the pragmatic path.VERDICT: NOT APPROVED
Fix required: Add test coverage for
team_idsintests/test_account.py(assert field presence intest_response_fields, assert correct values intest_includes_team_nameor a new dedicated test). Document theis_publicadmin change in the PR body.7e704c1a095405b3af8eQA fixes applied
BLOCKER fixed: Added
test_includes_team_ids— asserts Jordan has[sample_team.id]and Alex has[]. Also addedteam_idstotest_response_fieldsassertions.Scope creep fixed: Rebased onto Forgejo's current
main(5ad9fab). Theis_publicchange is no longer in this PR's diff. Clean 2-file diff:account.py(2 additions) +test_account.py(16 additions).10 tests passing (7 existing + 3 from upstream + 1 new
test_includes_team_ids).PR #334 Review (Re-review)
Previous review identified two issues: (1) missing test for
team_idsfield, (2) scope creep withis_publicchanges. This re-review verifies both fixes.DOMAIN REVIEW
Stack: Python / FastAPI / SQLAlchemy / Pydantic
Schema change --
AccountPlayerResponsegainsteam_ids: list[int]at line 32. Type is correct (Pydanticlist[int]). No default needed since it is always populated explicitly in the constructor.Population --
team_ids=[t.id for t in player.teams]at line 102. This mirrors the identical pattern in the admin route (admin.py:742). Theplayer.teamsM2M relationship is already eager-loaded viasubqueryload(Player.teams)on line 70, so no N+1 query risk.Backwards compatibility -- The existing
team_nameandteam_idfields are untouched. Newteam_idsfield is additive only. Zero-team players correctly produce[].Model verification --
Player.teamsis a proper M2M viaplayer_teamssecondary table withlazy="selectin"default loading (models.py:258-259). The explicitsubqueryloadin the query overrides this, which is fine.Scope creep check -- No
is_publicreferences exist inaccount.py. The previous scope creep has been fully removed. Diff touches exactly 2 files with 18 additions and 0 deletions, all directly related to theteam_idsfeature.BLOCKERS
None.
Previous blockers resolved:
test_includes_team_idsadded (lines 201-214). Tests both the assigned case (jordan["team_ids"] == [sample_team.id]) and the unassigned case (alex["team_ids"] == []). Uses thesample_teamfixture for exact ID comparison rather than hardcoded values.is_publicchanges are gone. Onlyteam_ids-related changes remain.Additionally,
test_response_fields(line 307) now asserts"team_ids" in player, ensuring the field presence is validated in the exhaustive field check.NITS
None.
SOP COMPLIANCE
333-add-team-ids-account-response)story:WS-S28) and architecture (arch-auth-westside-basketball)test_includes_team_ids+test_response_fieldsupdatedPROCESS OBSERVATIONS
Clean fix cycle. Both previous review findings addressed correctly. The pattern follows the established
team_idsconvention from the admin route, maintaining consistency across parent and admin response models. Low change-failure risk -- additive field on an existing endpoint with test coverage for both happy path (player with team) and edge case (player with no team).VERDICT: APPROVED