fix: populate team_name in PracticeScheduleResponse from Team join #342
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!342
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "341-populate-team-name"
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
Adds
team_nametoPracticeScheduleResponseso the frontend can group practices by team name without a separate lookup.Changes
src/basketball_api/routes/schedule.py-- Addedteam_name: str | None = Nonefield toPracticeScheduleResponse. Updated_practice_to_response()to populateteam_namefrompractice.team.name. Addedjoinedload(PracticeSchedule.team)to adminget_scheduleandlist_practicesqueries. Addedjoinedloadto imports.src/basketball_api/routes/public.py-- Addedjoinedload(PracticeSchedule.team)to the public schedule query.Test Plan
curl /public/schedule | jq '.practices[0].team_name'should return the team name string instead of null/scheduleand/schedule/practicesendpoints also returnteam_nameReview Checklist
Related Notes
Related
Closes #341
QA Review -- PR #342
Scope Check
PR targets issue #341 (populate
team_nameinPracticeScheduleResponse). The core commit (39a69c0) addresses exactly the three changes specified in the issue.Note: The diff includes an unrelated commit (
3c167ea--is_publicin admin players) that was on the local main ahead oforigin/main. This will resolve cleanly once that commit lands on the remote main. Not a blocker.Code Review
Schema --
team_name: str | None = Noneadded toPracticeScheduleResponsein the correct position (afterteam_id, beforeis_active). Optional field with None default means zero breaking change for existing consumers.Population --
team_name=ps.team.name if ps.team else Nonein_practice_to_response()is correct. Handles the null case when no team is assigned.Eager loading --
joinedload(PracticeSchedule.team)added to all three query sites:public.pypublic_schedule()-- correctschedule.pyget_schedule()(admin combined) -- correctschedule.pylist_practices()(admin list) -- correctThis prevents N+1 queries when iterating practices. CUD endpoints (
create_practice,update_practice) usedb.refresh()which will lazy-load the team within the same session -- acceptable for single-object returns.Tests
groupme_sdkimport failure)Nits
None. Clean, minimal change.
VERDICT: APPROVED
39a69c098c706a7b3687